19
19
#ifndef __CStrLiteral_h__
20
20
#define __CStrLiteral_h__
23
* String literal abstraction. */
22
25
#include "Puma/CExprValue.h"
30
/** \class CStrLiteral CStrLiteral.h Puma/CStrLiteral.h
31
* String literal abstraction. Holds the string value,
32
* its length, and the string type. */
27
33
class CStrLiteral : public CExprValue {
28
34
const char *_string;
29
35
unsigned long _len;
39
* \param s The string array.
40
* \param len The length of the string.
41
* \param t The type of the string. */
32
42
CStrLiteral (const char *s, unsigned long len, CTypeInfo *t) :
33
43
CExprValue (t), _string (s), _len (len) {}
44
/** Destructor. Frees the string. */
34
45
virtual ~CStrLiteral () { if (_string) delete[] _string; }
47
/** Print the string on the given output stream.
48
* \param out The output stream. */
36
49
virtual void print (ostream &out) const { out << "\"" << String () << "\""; }
50
/** Get the wide string. */
37
51
const char *String () const { return _string; }
52
/** Get the length of the string. */
38
53
unsigned long Length () const { return _len; }
40
56
CStrLiteral *StrLiteral () const { return (CStrLiteral*)this; }