KSquare Utilities
XmlStream.cpp File Reference
#include "FirstIncludes.h"
#include <stdio.h>
#include <fstream>
#include <string.h>
#include <string>
#include <iostream>
#include <ostream>
#include <vector>
#include "MemoryDebug.h"
#include "BitString.h"
#include "GlobalGoalKeeper.h"
#include "KKBaseTypes.h"
#include "KKException.h"
#include "KKStrParser.h"
#include "XmlTokenizer.h"
#include "XmlStream.h"

Go to the source code of this file.

Classes

class  XmlFactoryArrayDouble
 
class  XmlFactoryArrayFloat
 
class  XmlFactoryArrayFloat2D
 
class  XmlFactoryArrayFloat2DVarying
 
class  XmlFactoryArrayInt32
 
class  XmlFactoryArrayUint16
 
class  XmlFactoryBool
 
class  XmlFactoryDateTime
 
class  XmlFactoryDouble
 
class  XmlFactoryFloat
 
class  XmlFactoryInt32
 
class  XmlFactoryInt64
 
class  XmlFactoryKeyValuePairs
 
class  XmlFactoryKKStr
 
class  XmlFactoryKKStrList
 
class  XmlFactoryKKStrListIndexed
 
class  XmlFactoryUnKnown
 
class  XmlFactoryVectorFloat
 
class  XmlFactoryVectorInt32
 
class  XmlFactoryVectorKKStr
 

Macros

#define XmlElementArray2DBody(T, TypeName, XmlElementToUse)
 
#define XmlElementArrayBody(T, TypeName, ParserNextTokenMethod)
 
#define XmlElementBuiltInTypeBody(T, TypeName, ParseMethod)
 
#define XmlElementVectorBody(T, TypeName, ParserNextTokenMethod)
 

Functions

void ExtractAttribute (KKStr &tagStr, KKStr &attributeName, KKStr &attributeValue)
 
void ReadWholeTag (istream &i, KKStr &tagStr)
 

Variables

kkint32 xmlLevel = 0
 

Macro Definition Documentation

#define XmlElementArray2DBody (   T,
  TypeName,
  XmlElementToUse 
)

Works with corresponding macro (XmlElementArray2DHeader) defined in header file "XmlStream.h"

Parameters
TThe Built-In type, examples: float, kkint32, double, ...
TypeNameThe name we give the type ex: "Int32", "Float", ....
XmlElementToUsethe XmlElement derived class that will be used to process each row in the matrix.

Definition at line 1613 of file XmlStream.cpp.

#define XmlElementArrayBody (   T,
  TypeName,
  ParserNextTokenMethod 
)

Definition at line 1496 of file XmlStream.cpp.

#define XmlElementBuiltInTypeBody (   T,
  TypeName,
  ParseMethod 
)

Works with matching Marco (XmlElementBuiltInTypeHeader) defined in XmlStream.h

Definition at line 1438 of file XmlStream.cpp.

#define XmlElementVectorBody (   T,
  TypeName,
  ParserNextTokenMethod 
)

Definition at line 1758 of file XmlStream.cpp.

Function Documentation

void ExtractAttribute ( KKStr tagStr,
KKStr attributeName,
KKStr attributeValue 
)

Definition at line 412 of file XmlStream.cpp.

References KKB::KKStr::Len(), KKB::KKStr::operator=(), KKB::KKStr::operator[](), and KKB::KKStr::SubStrPart().

416 {
417  kkint32 startIdx = 0;
418  kkint32 len = tagStr.Len ();
419  attributeName = "";
420  attributeValue = "";
421 
422  // Skip over leading spaces
423  while (startIdx < len)
424  {
425  if (strchr ("\n\t\r ", tagStr[startIdx]) == NULL)
426  break;
427  startIdx++;
428  }
429 
430  if (startIdx >= len)
431  {
432  tagStr = "";
433  return;
434  }
435 
436  kkint32 idx = startIdx;
437 
438  // Skip until we find the '=' character.
439  while (idx < len)
440  {
441  if (tagStr[idx] == '=')
442  break;
443  ++idx;
444  }
445 
446  if (idx >= len)
447  {
448  tagStr = "";
449  return;
450  }
451 
452  attributeName = tagStr.SubStrPart (startIdx, idx - 1);
453 
454  ++idx; // Skip past '=' character.
455 
456  // Skip over leading spaces
457  while (idx < len)
458  {
459  if (strchr ("\n\t\r ", tagStr[idx]) == NULL)
460  break;
461  ++idx;
462  }
463 
464  if (idx >= len)
465  {
466  tagStr = "";
467  return;
468  }
469 
470  int valueStartIdx = idx;
471 
472  while (idx < len)
473  {
474  if (strchr ("\n\t\r ", tagStr[idx]) != NULL)
475  break;
476  ++idx;
477  }
478 
479  attributeValue = tagStr.SubStrPart (valueStartIdx, idx - 1);
480 
481  tagStr = tagStr.SubStrPart (idx + 1);
482 
483  return;
484 } /* ExtractAttribute */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
void ReadWholeTag ( istream &  i,
KKStr tagStr 
)

Definition at line 390 of file XmlStream.cpp.

References KKB::KKStr::operator=().

393 {
394  tagStr = "";
395  while (!i.eof ())
396  {
397  char nextCh = i.get ();
398  if (nextCh != 0)
399  tagStr.Append (nextCh);
400  if (nextCh == '>')
401  break;
402  }
403 
404  return;
405 } /* ReadWholeTag */
void Append(const char *buff)
Definition: KKStr.cpp:1783

Variable Documentation

kkint32 xmlLevel = 0

Definition at line 720 of file XmlStream.cpp.

Referenced by KKB::XmlTag::WriteXML().