libcsdbg  1.28
C++ exception (and generic) stack trace debug library
string.hpp
Go to the documentation of this file.
1 #ifndef _CSDBG_STRING
2 #define _CSDBG_STRING 1
3 
10 #if defined CSDBG_WITH_PLUGIN || defined CSDBG_WITH_HIGHLIGHT
11 #include "./chain.hpp"
12 #else
13 #include "./object.hpp"
14 #endif
15 
16 namespace csdbg {
17 
36 class string: virtual public object
37 {
38 protected:
39 
40  /* Protected variables */
41 
49  /* Protected generic methods */
50 
51  virtual string& memalign(u32, bool = false);
52 
53  virtual string& format(const i8*, va_list);
54 
55 public:
56 
57  /* Friend classes and functions */
58 
59  friend std::ostream& operator<<(std::ostream&, const string&);
60 
61 
62  /* Constructors, copy constructors and destructor */
63 
64  explicit string(u32 = 0);
65 
66  string(const i8*, ...);
67 
68  string(const string&);
69 
70  virtual ~string();
71 
72  virtual string* clone() const;
73 
74 
75  /* Accessor methods */
76 
77  virtual const i8* cstr() const;
78 
79  virtual u32 length() const;
80 
81  virtual u32 bufsize() const;
82 
83  virtual i8& at(u32);
84 
85  virtual string& set(const i8*, ...);
86 
87  virtual string& set(const string&);
88 
89 
90  /* Operator overloading methods */
91 
92  virtual string& operator=(const string&);
93 
94  virtual string& operator+=(const string&);
95 
96  virtual i8& operator[](u32);
97 
98 
99  /* Generic methods */
100 
101  virtual u32 available() const;
102 
103  virtual string& shred(u8 = 0);
104 
105  virtual string& clear();
106 
107  virtual string& append(const string&);
108 
109  virtual string& append(const i8*, ...);
110 
111  virtual string& append(i8);
112 
113  virtual i32 cmp(const string&, bool = false) const;
114 
115  virtual bool match(const string&, bool = false) const;
116 
117 #if defined CSDBG_WITH_PLUGIN || defined CSDBG_WITH_HIGHLIGHT
118  virtual string& trim(i32 = 0);
119 
120  virtual string& insert(u32, const string&);
121 
122  virtual string& insert(u32, const i8*, ...);
123 
124  virtual chain<string>* split(const string&, bool = true, bool = false) const;
125 #endif
126 };
127 
128 }
129 
130 #endif
131 
virtual string & trim(i32=0)
Remove leading and/or trailing whitespace characters.
Definition: string.cpp:529
virtual string & append(const string &)
Append a string.
Definition: string.cpp:404
virtual string * clone() const
Object virtual copy constructor.
Definition: string.cpp:200
This abstract class serves as the root of the class hierarchy tree.
Definition: object.hpp:17
virtual string & set(const i8 *,...)
Fill with a printf-style format C-string expanded with the values of a variable argument list...
Definition: string.cpp:271
virtual u32 available() const
Get the available buffer size, the number of characters that can be appended without reallocation...
Definition: string.cpp:360
virtual u32 bufsize() const
Get the buffer size.
Definition: string.cpp:233
virtual string & operator+=(const string &)
Compound addition-assignment operator (append)
Definition: string.cpp:332
virtual string & format(const i8 *, va_list)
Fill with a printf-style format C-string expanded with the values of a variable argument list...
Definition: string.cpp:79
char i8
8-bit signed integer
Definition: config.hpp:72
virtual ~string()
Object destructor.
Definition: string.cpp:186
Class csdbg::object definition.
friend std::ostream & operator<<(std::ostream &, const string &)
Stream insertion operator for csdbg::string objects.
Definition: string.cpp:114
virtual string & operator=(const string &)
Assignment operator.
Definition: string.cpp:317
Class csdbg::chain definition and method implementation.
virtual string & insert(u32, const string &)
Insert a string at a specified position.
Definition: string.cpp:575
string(u32=0)
Object constructor.
Definition: string.cpp:127
virtual string & memalign(u32, bool=false)
Allocate aligned memory, mandate a minimum buffer size.
Definition: string.cpp:26
virtual i8 & operator[](u32)
Subscript operator.
Definition: string.cpp:347
unsigned char u8
8-bit unsigned integer
Definition: config.hpp:92
virtual string & clear()
Clear contents.
Definition: string.cpp:387
virtual i32 cmp(const string &, bool=false) const
Compare to another string.
Definition: string.cpp:470
virtual i8 & at(u32)
Get/set the character at an offset.
Definition: string.cpp:248
virtual const i8 * cstr() const
Get the C-string equivalent.
Definition: string.cpp:211
Lightweight string buffer class (for ISO-8859-1 text)
Definition: string.hpp:36
virtual bool match(const string &, bool=false) const
Match against a POSIX extended regular expression.
Definition: string.cpp:490
u32 m_size
Buffer size.
Definition: string.hpp:46
i8 * m_data
String data.
Definition: string.hpp:42
unsigned int u32
32-bit unsigned integer
Definition: config.hpp:102
int i32
32-bit signed integer
Definition: config.hpp:82
virtual u32 length() const
Get the character count.
Definition: string.cpp:222
virtual string & shred(u8=0)
Fill the whole buffer with a constant byte.
Definition: string.cpp:375
virtual chain< string > * split(const string &, bool=true, bool=false) const
Tokenize using a POSIX extended regular expression.
Definition: string.cpp:642
u32 m_length
Character count.
Definition: string.hpp:44