| 202 | {} |
| 203 | |
| 204 | bool CGPGroup::Parse( gsl::cstring_view& data, const bool topLevel ) |
| 205 | { |
| 206 | while ( true ) |
| 207 | { |
| 208 | gsl::cstring_view token = GetToken( data, true ); |
| 209 | |
| 210 | if ( token.empty() ) |
| 211 | { |
| 212 | if ( topLevel ) |
| 213 | { |
| 214 | // top level parse; there was no opening "{", so there should be no closing one either. |
| 215 | return true; |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | // end of data - error! |
| 220 | return false; |
| 221 | } |
| 222 | } |
| 223 | else if ( token == CSTRING_VIEW( "}" ) ) |
| 224 | { |
| 225 | if ( topLevel ) |
| 226 | { |
| 227 | // top-level group; there was no opening "{" so there should be no closing one, either. |
| 228 | return false; |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | // ending brace for this group |
| 233 | return true; |
| 234 | } |
| 235 | } |
| 236 | gsl::cstring_view lastToken = token; |
| 237 | |
| 238 | // read ahead to see what we are doing |
| 239 | token = GetToken( data, true, true ); |
| 240 | if ( token == CSTRING_VIEW( "{" ) ) |
| 241 | { |
| 242 | // new sub group |
| 243 | mSubGroups.emplace_back( lastToken ); |
| 244 | if ( !mSubGroups.back().Parse( data, false ) ) |
| 245 | { |
| 246 | return false; |
| 247 | } |
| 248 | } |
| 249 | else if ( token == CSTRING_VIEW( "[" ) ) |
| 250 | { |
| 251 | // new list |
| 252 | mProperties.emplace_back( lastToken ); |
| 253 | CGPProperty& list = mProperties.back(); |
| 254 | while ( true ) |
| 255 | { |
| 256 | token = GetToken( data, true, true ); |
| 257 | if ( token.empty() ) |
| 258 | { |
| 259 | return false; |
| 260 | } |
| 261 | if ( token == CSTRING_VIEW( "]" ) ) |