A class that wraps strings. Normally stores the start and end pointers into the XML file itself, and will apply normalization and entity translation if actually read. Can also store (and memory manage) a traditional char[] */
| 144 | manage) a traditional char[] |
| 145 | */ |
| 146 | class StrPair |
| 147 | { |
| 148 | public: |
| 149 | enum { |
| 150 | NEEDS_ENTITY_PROCESSING = 0x01, |
| 151 | NEEDS_NEWLINE_NORMALIZATION = 0x02, |
| 152 | COLLAPSE_WHITESPACE = 0x04, |
| 153 | |
| 154 | TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, |
| 155 | TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, |
| 156 | ATTRIBUTE_NAME = 0, |
| 157 | ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, |
| 158 | ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, |
| 159 | COMMENT = NEEDS_NEWLINE_NORMALIZATION |
| 160 | }; |
| 161 | |
| 162 | StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} |
| 163 | ~StrPair(); |
| 164 | |
| 165 | void Set( char* start, char* end, int flags ) { |
| 166 | Reset(); |
| 167 | _start = start; |
| 168 | _end = end; |
| 169 | _flags = flags | NEEDS_FLUSH; |
| 170 | } |
| 171 | |
| 172 | const char* GetStr(); |
| 173 | |
| 174 | bool Empty() const { |
| 175 | return _start == _end; |
| 176 | } |
| 177 | |
| 178 | void SetInternedStr( const char* str ) { |
| 179 | Reset(); |
| 180 | _start = const_cast<char*>(str); |
| 181 | } |
| 182 | |
| 183 | void SetStr( const char* str, int flags=0 ); |
| 184 | |
| 185 | char* ParseText( char* in, const char* endTag, int strFlags ); |
| 186 | char* ParseName( char* in ); |
| 187 | |
| 188 | private: |
| 189 | void Reset(); |
| 190 | void CollapseWhitespace(); |
| 191 | |
| 192 | enum { |
| 193 | NEEDS_FLUSH = 0x100, |
| 194 | NEEDS_DELETE = 0x200 |
| 195 | }; |
| 196 | |
| 197 | // After parsing, if *_end != 0, it can be set to zero. |
| 198 | int _flags; |
| 199 | char* _start; |
| 200 | char* _end; |
| 201 | }; |
| 202 | |
| 203 |
nothing calls this directly
no outgoing calls
no test coverage detected