KSquare Utilities
XmlStream.h
Go to the documentation of this file.
1 /* XmlStream.h -- Class to XML Objects; still in development.
2  * Copyright (C) 1994-2011 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in KKB.h
4  */
5 #ifndef _XMLSTREAM_
6 #define _XMLSTREAM_
7 #include <map>
8 
9 #include "DateTime.h"
10 #include "KKStr.h"
11 #include "RunLog.h"
12 #include "XmlTokenizer.h"
13 
14 using namespace KKB;
15 
16 namespace KKB
17 {
18  class XmlToken;
19  typedef XmlToken* XmlTokenPtr;
20 
21  class XmlElement;
22  typedef XmlElement* XmlElementPtr;
23 
24  class XmlContent;
25  typedef XmlContent* XmlContentPtr;
26 
27  class XmlFactory;
28  typedef XmlFactory* XmlFactoryPtr;
29 
32 
33 
34 
35  /**
36  *@class XmlStream XmlStream.h
37  *@brief Manages the reading and writing of objects in a simple XML format.
38  * For a class to be supported by XmlStream it must implement:
39  * - Default constructor.
40  * - Helper Class derived form XmlElement
41  * - Helper Class derived from XmlFactory
42  * - Method XmlRead
43  * - Method XmlWrite
44  *
45  */
46  class XmlStream
47  {
48  public:
50 
51  XmlStream (XmlTokenizerPtr _tokenStream);
52 
53  XmlStream (const KKStr& _fileName, RunLog& _log);
54 
55  virtual ~XmlStream ();
56 
57  /** Will return either a XmlElement or a XmlContent which ever is next; If we are at the end of the element then NULL will be returned. */
58  virtual XmlTokenPtr GetNextToken (VolConstBool& cancelFlag,
59  RunLog& log
60  );
61 
62  virtual XmlContentPtr GetNextContent (RunLog& log); /**< Will return any content that may exist before the next tag; if
63  * there is no content before the next tag will return NULL
64  */
65 
66  void RegisterFactory (XmlFactoryPtr factory); /** Registers factory with the highest level FactoryManager in 'factoryManagers'. */
67 
68 
69  private:
70  /**
71  *@brief returns the index of the latest instance of 'name' pushed onto the stack; if no entry with the same name returns -1.
72  */
73  kkint32 FindLastInstanceOnElementNameStack (const KKStr& name);
74 
75 
76  void PushXmlElementLevel (const KKStr& sectionName);
77 
78  void PopXmlElementLevel ();
79 
80  XmlFactoryPtr TrackDownFactory (const KKStr& sectionName); /** Will search for the factory starting at the highest level of 'factoryManagers'
81  * the working down the stack; if not found there will then look at the
82  'XmlFactory::globalXmlFactoryManager'
83  */
84 
85 
86  /**
87  * When we start a new element the name of the Section is pushed on the back of 'endOfElementTagNames'. This
88  * is how we keep track of the End tag that we are looking for to close out the current element. The member
89  * 'factoryManagers' works in synchronization with endOfElementTagNames. That is when we start a new Element
90  * we push an empty 'XmlFactoryManager' instance onto 'factoryManagers'. This will allow XmlElement derived
91  * classes to specify 'XmlFactory' derived instances that are specific to their universe. An example use would
92  * be the 'TrainingProcess2' class requiring to add a XmlElement factory for 'Model' derived classes. These
93  * Factory derived classes would contain a cancelFlag reference that they pass in the constructor to all
94  */
95  VectorKKStr endOfElementTagNames;
96  std::vector<XmlFactoryManagerPtr> factoryManagers;
97 
98 
99  bool endOfElemenReached;
100  KKStr fileName;
101  KKStr nameOfLastEndTag;
102  XmlTokenizerPtr tokenStream;
103  bool weOwnTokenStream;
104  }; /* XmlStream */
105 
106 
108 
109 #define _XmlStream_Defined_
110 
111 
113  {
114  public:
115  XmlAttribute (const KKStr& _name,
116  const KKStr& _value
117  ):
118  name (_name),
119  value (_value)
120  {}
121 
122  const KKStr& Name () const {return name;}
123  const KKStr& Value () const {return value;}
124 
125  private:
126  KKStr name;
127  KKStr value;
128  };
129 
133 
134 
135 
137  {
138  public:
139  XmlAttributeList (bool _owner);
140  XmlAttributeList (const XmlAttributeList& attributes);
141 
142  void AddAttribute (const KKStr& name,
143  const KKStr& value
144  );
145 
146  virtual void PushOnBack (XmlAttributePtr a);
147  virtual void PushOnFront (XmlAttributePtr a);
148 
149  virtual XmlAttributePtr PopFromBack ();
150  virtual XmlAttributePtr PopFromFromt ();
151 
152  XmlAttributePtr LookUpByName (const KKStr& name) const;
153 
154  KKStrConstPtr AttributeValueByName (const KKStr& name) const;
155  KKStrConstPtr AttributeValueByIndex (kkuint32 index) const;
156  KKStrConstPtr AttributeNameByIndex (kkuint32 index) const;
157 
158  const KKStr& AttributeValueKKStr (const KKStr& name) const;
159  kkint32 AttributeValueInt32 (const KKStr& name) const;
160  DateTime AttributeValueDateTime (const KKStr& name) const;
161 
162  private:
163  void DeleteFromNameIndex (XmlAttributePtr a);
164 
165  typedef std::multimap<KKStr,XmlAttributePtr> NameIndex;
166  typedef std::pair<KKStr,XmlAttributePtr> NameIndexPair;
167  NameIndex nameIndex;
168  }; /* XmlAttributeList */
169 
171 
172  class XmlTag
173  {
174  public:
175  typedef XmlTag* XmlTagPtr;
177 
178  XmlTag (const KKStrConstPtr tagStr);
179 
180  XmlTag (const KKStr& _name,
181  TagTypes _tagType
182  );
183 
184  virtual ~XmlTag ();
185 
186  ///<summary>Will construct a generic XML tag from the following characters in the stream.</summary>
187  ///<remarks>
188  ///It is assumed that the next character read from the input stream <paramref name="i"/> will be &lt;; if not then it is assumed that the next
189  ///character is the one immediately following the &lt;.
190  ///</remarks>
191  XmlTag (std::istream& i);
192 
193  const KKStr& Name () const {return name;}
194  TagTypes TagType () const {return tagType;}
195 
196  kkint32 AttributeCount () const {return (kkint32)attributes.size ();}
197 
198  const XmlAttributeList& Attributes () const {return attributes;}
199 
200  KKStrConstPtr AttributeValueByName (const KKStr& name) const;
201  KKStrConstPtr AttributeValueByIndex (kkuint32 index) const;
202  KKStrConstPtr AttributeNameByIndex (kkuint32 index) const;
203 
204  const KKStr& AttributeValueKKStr (const KKStr& name) const;
205  kkint32 AttributeValueInt32 (const KKStr& attributeName) const;
206  DateTime AttributeValueDateTime (const KKStr& attributeName) const;
207 
208 
209  void AddAtribute (const KKStr& attributeName,
210  const KKStr& attributeValue
211  );
212 
213  void AddAtribute (const KKStr& attributeName,
214  bool attributeValue
215  );
216 
217  void AddAtribute (const KKStr& attributeName,
218  kkint32 attributeValue
219  );
220 
221  void AddAtribute (const KKStr& attributeName,
222  kkint64 attributeValue
223  );
224 
225  void AddAtribute (const KKStr& attributeName,
226  double attributeValue
227  );
228 
229  void AddAtribute (const KKStr& attributeName,
230  const DateTime& attributeValue
231  );
232 
233  KKStr ToString () const;
234 
235  void WriteXML (std::ostream& o);
236 
237  private:
238  KKStr name;
239  XmlAttributeList attributes;
240  TagTypes tagType;
241  }; /* XmlTag */
242 
243  typedef XmlTag::XmlTagPtr XmlTagPtr;
244  typedef XmlTag const XmlTagConst;
245  typedef XmlTagConst* XmlTagConstPtr;
246 
247 #define _XmlTag_Defined_
248 
249 
250 
251  ///<Summary>@brief The parent Class to the two type of tokens, "XmlElement" and "XmlContent"</Summary>
252  class XmlToken
253  {
254  public:
257 
258  XmlToken ();
259  virtual ~XmlToken ();
260 
261  virtual TokenTypes TokenType () = 0;
262 
263 
264  /** If derived class is from the XmlElement family will be the name from the StartTag(XmlTag::Name ()) otherwise KKStr::EmptyStr() */
265  virtual const KKStr& SectionName () const {return KKStr::EmptyStr ();}
266 
267 
268  /** If the derived class is form the 'XmlElement' line will return the 'VarName' from that derived class otherwise it will return back a empty string. */
269  virtual const KKStr& VarName () const {return KKStr::EmptyStr ();}
270 
271  private:
272  }; /* XmlToken */
273 
275 
276 
277 
278  ///<Summary>Parent class to all XmlElements</Summary>
279  ///<remarks> When XmlStream encounters the start of a element it looks up the appropriate ElementFactory that will construct an instance of a XmlElement
280  /// derived class. The constructor of that class will be provided the XmlTag that starts the element plus a pointer to the XmlStream instance
281  /// that is reading the XML file. The XmlElement derived classes constructor will the be responsible for creating an instance of the class
282  /// that the XmnlElement wraps.</remarks>
283  class XmlElement: public XmlToken
284  {
285  public:
287 
288  XmlElement (const KKStr& sectionName,
289  XmlTag::TagTypes tagType
290  );
291 
292  XmlElement (XmlTagPtr _nameTag,
293  XmlStream& s,
294  RunLog& log
295  );
296 
297  virtual ~XmlElement ();
298 
299  XmlTagConstPtr NameTag () const {return nameTag;}
300 
301  KKStr NameTagStr () const; /**< The initial start tag with its attributes that started the element. */
302 
303  virtual const KKStr& SectionName () const;
304 
306 
307  virtual const KKStr& VarName () const;
308 
309  KKStrConstPtr AttributeValue (const char* attributeName);
310  KKStrConstPtr AttributeValue (const KKStr& attributeName);
311 
312  // derived classes may choose to implement any of the following as per what makes sense.
313  virtual bool ToBool () const {return false;}
314  virtual KKStr ToKKStr () const {return nameTag->ToString ();}
315  virtual double ToDouble () const {return 0.0;}
316  virtual float ToFloat () const {return 0.0f;}
317  virtual kkint32 ToInt32 () const {return 0;}
318 
319  private:
320  XmlTagPtr nameTag;
321  }; /* XmlElement */
322 
324 
325 
326 
327 
328  class XmlContent: public XmlToken
329  {
330  public:
332 
333  XmlContent (KKStrPtr _content);
334  virtual ~XmlContent ();
335 
337 
338  KKStrPtr const Content () const {return content;}
339  KKStrPtr TakeOwnership ();
340 
341  static
342  void WriteXml (const KKStr& s,
343  std::ostream& o
344  );
345 
346  private:
347  KKStrPtr content;
348  }; /* XmlContent */
349 
350  typedef XmlContent* XmlContentPtr;
351 
352 
353 
354 
355 
356 
358  {
359  public:
360  XmlFactoryManager (const KKStr& _name);
361 
362  ~XmlFactoryManager ();
363 
364 
365  ///<summary>Give the FactoryManager instance ownership of this factory; the name of the factory must be unique.</summary>
366  void RegisterFactory (XmlFactory* factory);
367 
368  XmlFactory* FactoryLookUp (const KKStr& className) const;
369 
370  private:
371  std::map<KKStr, XmlFactory*> factories;
372  KKStr name;
373  }; /* XmlFactoryManager */
374 
376 
377 
378 
379 
380 
381 
383  {
384  public:
385  XmlFactory (const KKStr& _clasName);
386 
387  virtual const KKStr& ClassName () const {return className;}
388 
390  XmlStream& s,
391  VolConstBool& cancelFlag,
392  RunLog& log
393  ) = 0;
394 
395  static XmlFactory* FactoryLookUp (const KKStr& className);
396 
397  ///<summary>Register a instance of a Derives Factory class for the Global XmlFactoryManager.</summary>
398  ///<param name = 'factory'> The instance that is being registered; factories will take ownership and the method
399  /// 'XmlStream' will be responsible for deleting upon application shutdown.</param>
400  static void RegisterFactory (XmlFactory* factory);
401 
403 
404  static void FinalCleanUp ();
405  private:
406  KKStr className; /**< Class that this factory produces instances of. */
407 
408  }; /* XmlFactory */
409 
410  typedef XmlFactory* XmlFactoryPtr;
412 
413 
414 
415 
416 
417  ///<summary>To be used for classes that implement default constructor, ReadXML, and WriteXML.</summary>
418  template<class T>
420  {
421  public:
423  XmlStream& s,
424  VolConstBool& cancelFlag,
425  RunLog& log
426  ):
427  XmlElement (tag, s, log),
428  value (NULL)
429  {
430  value = new T();
432  }
433 
434 
436  {
437  delete value;
438  value = NULL;
439  }
440 
441  T* const Value () const {return value;}
442 
444  {
445  T* v = value;
446  value = NULL;
447  return v;
448  }
449 
450  static
451  void WriteXML (const T& t,
452  const KKStr& varName,
453  std::ostream& o
454  )
455  {
456  t.WriteXML (varName, o);
457  }
458 
459  private:
460  T* value;
461  }; /* XmlElementTemplate */
462 
463 
464 
465  /****************************************************************************/
466 
467 
468  ///<summary>XmlElement derived class that will be used when there is no Factory defined for the element.</summary>
469  ///<remarks>All sub-elements and content will be saved in value which will be a list of XmlEemenst and
470  ///content.</remarks>
472  {
473  public:
475  XmlStream& s,
476  VolConstBool& cancelFlag,
477  RunLog& log
478  );
479 
480  virtual ~XmlElementUnKnown ();
481 
482  std::deque<XmlTokenPtr>* Value () const {return value;}
483 
485 
486 
487  private:
488  std::deque<XmlTokenPtr>* value;
489  };
491 
493 
494 
495  /****************************************************************************/
497  {
498  public:
500  XmlStream& s,
501  VolConstBool& cancelFlag,
502  RunLog& log
503  );
504 
505  virtual ~XmlElementBool ();
506 
507  bool Value () const;
508 
509  static
510  void WriteXML (const bool b,
511  const KKStr& varName,
512  std::ostream& o
513  );
514 
515  virtual bool ToBool () const {return value;}
516  virtual KKStr ToKKStr () const {return value ? "True" : "False";}
517  virtual double ToDouble () const {return (double)value;}
518  virtual float ToFloat () const {return (float)value;}
519  virtual kkint32 ToInt32 () const {return (kkint32)value;}
520 
521  private:
522  bool value;
523  };
525 
526 
527 
528 
529 
530 
531  /****************************************************************************/
533  {
534  public:
536  XmlStream& s,
537  VolConstBool& cancelFlag,
538  RunLog& log
539  );
540 
541  virtual ~XmlElementDateTime ();
542 
543  DateTime Value () const {return value;}
544 
545  static
546  void WriteXML (const DateTime& d,
547  const KKStr& varName,
548  std::ostream& o
549  );
550 
551  virtual bool ToBool () const {return (value.Seconds () > 0);}
552  virtual KKStr ToKKStr () const {return value.YYYY_MM_DD_HH_MM_SS ();}
553  virtual double ToDouble () const {return (double)value.Seconds ();}
554  virtual float ToFloat () const {return (float)value.Seconds ();}
555  virtual kkint32 ToInt32 () const {return (kkint32)value.ToDays ();}
556 
557  private:
558  DateTime value;
559  };
561 
562 
563 
564 
565 
566 
567  /****************************************************************************/
569  {
570  public:
571 
572  ///<summary>Used to construct an instance that will be written out to a XML file.</summary>
574 
575 
576  ///<summary>Used while from XmlStream while reading file; every time it comes across a new Section(Start-Tag)
577  ///a new instance of this class will be instantiated.</summary>
579  XmlStream& s,
580  VolConstBool& cancelFlag,
581  RunLog& log
582  );
583 
584  virtual ~XmlElementKeyValuePairs ();
585 
586  std::vector<std::pair<KKStr,KKStr> >* Value () const {return value;}
587 
589 
590  void Add (const KKStr& key, const KKStr& v);
591  void Add (const KKStr& key, kkint32 v);
592  void Add (const KKStr& key, float v);
593  void Add (const KKStr& key, double v);
594  void Add (const KKStr& key, bool v);
595  void Add (const KKStr& key, const KKB::DateTime& v);
596 
597  void WriteXML (const KKStr& varName,
598  std::ostream& o
599  );
600 
601  private:
602  std::vector<std::pair<KKStr,KKStr> >* value;
603  }; /* XmlElementKeyValuePairs */
604 
606 
607 
608 
609 
610 
612  {
613  public:
615  XmlStream& s,
616  VolConstBool& cancelFlag,
617  RunLog& log
618  );
619 
620  virtual ~XmlElementArrayFloat2DVarying ();
621 
622  kkuint32 Height () const {return height;}
623 
624  float** Value () const {return value;}
625 
626  kkuint32* Widths () const {return widths;}
627 
628  float** TakeOwnership ();
629 
631 
632  static
633  void WriteXML (kkuint32 height,
634  const kkint32* widths, /**< Each entry in array defines the length of the corresponding row in 'mat'. */
635  float** const mat,
636  const KKStr& varName,
637  std::ostream& o
638  );
639 
640 
641  private:
642  kkuint32 height;
643  float** value;
644  kkuint32* widths;
645  };
646 
648 
649 
650 
651 
652 
654  {
655  public:
657  XmlStream& s,
658  VolConstBool& cancelFlag,
659  RunLog& log
660  ):
662  {}
663 
664  virtual bool ToBool () const {return (Value () ? Value ()->ToBool () : false);}
665  virtual KKStr ToKKStr () const {return (Value () ? *Value () : KKStr::EmptyStr ());}
666  virtual double ToDouble () const {return (Value () ? Value ()->ToDouble () : 0.0);}
667  virtual float ToFloat () const {return (Value () ? Value ()->ToFloat () : 0.0f);}
668  virtual kkint32 ToInt32 () const {return (Value () ? Value ()->ToInt32 () : 0);}
669  };
672 
673 
676 
677 
680 
681 
684 
685 
686 
687 
688 #define XmlFactoryMacro(NameOfClass)
689  class XmlFactory##NameOfClass: public XmlFactory
690  {
691  public:
692  XmlFactory##NameOfClass (): XmlFactory (#NameOfClass) {}
693 
694  virtual XmlElement##NameOfClass* ManufatureXmlElement (XmlTagPtr tag,
695  XmlStream& s,
696  VolConstBool& cancelFlag,
697  RunLog& log
698  )
699  {
700  return new XmlElement##NameOfClass(tag, s, cancelFlag, log);
701  }
702 
703  static XmlFactory##NameOfClass* factoryInstance;
704 
705  static XmlFactory##NameOfClass* FactoryInstance ()
706  {
707  if (factoryInstance == NULL)
708  {
709  GlobalGoalKeeper::StartBlock ();
710  if (!factoryInstance)
711  {
712  factoryInstance = new XmlFactory##NameOfClass ();
713  XmlFactory::RegisterFactory (factoryInstance);
714  }
715  GlobalGoalKeeper::EndBlock ();
716  }
717  return factoryInstance;
718  }
719  };
720 
721  XmlFactory##NameOfClass* XmlFactory##NameOfClass::factoryInstance
722  = XmlFactory##NameOfClass::FactoryInstance ();
723 
724 
725 
726 
727 /** To be used when the XmlElement derived class is defined as a member of the class in question. */
728 
729 #define XmlFactoryMacro2(NameOfClass)
730  class XmlFactory##NameOfClass: public XmlFactory
731  {
732  public:
733  XmlFactory##NameOfClass (): XmlFactory (#NameOfClass) {}
734  virtual XmlElement##NameOfClass* ManufatureXmlElement (XmlTagPtr tag,
735  XmlStream& s,
736  VolConstBool& cancelFlag,
737  RunLog& log
738  )
739  {
740  return new ##NameOfClass::Xml (tag, s, log);
741  }
742 
743  static XmlFactory##NameOfClass* factoryInstance;
744 
745  static XmlFactory##NameOfClass* FactoryInstance ()
746  {
747  if (factoryInstance == NULL)
748  {
749  GlobalGoalKeeper::StartBlock ();
750  if (!factoryInstance)
751  {
752  factoryInstance = new XmlFactory##NameOfClass ();
753  XmlFactory::RegisterFactory (factoryInstance);
754  }
755  GlobalGoalKeeper::EndBlock ();
756  }
757  return factoryInstance;
758  }
759  };
760 
761  XmlFactory##NameOfClass* XmlFactory##NameOfClass::factoryInstance
762  = XmlFactory##NameOfClass::FactoryInstance ();
763 
764 
765 
766 
767 
768 #define XmlElementBuiltInTypeHeader(T,TypeName)
769 
770  class XmlElement##TypeName: public XmlElement
771  {
772  public:
773  XmlElement##TypeName (XmlTagPtr tag,
774  XmlStream& s,
775  VolConstBool& cancelFlag,
776  RunLog& log
777  );
778 
779  virtual ~XmlElement##TypeName ();
780 
781  T Value () const {return value;}
782 
783  static
784  void WriteXML (T d,
785  const KKStr& varName,
786  std::ostream& o
787  );
788 
789  virtual bool ToBool () const;
790  virtual KKStr ToKKStr () const;
791  virtual double ToDouble () const;
792  virtual float ToFloat () const;
793  virtual kkint32 ToInt32 () const;
794  private:
795  T value;
796  };
797  typedef XmlElement##TypeName* XmlElement##TypeName##Ptr;
798 
799 
800 
801 
802 
803 
804 #define XmlElementArrayHeader(T,TypeName,ParserNextTokenMethod)
805  class XmlElement##TypeName: public XmlElement
806  {
807  public:
808  XmlElement##TypeName (XmlTagPtr tag,
809  XmlStream& s,
810  VolConstBool& cancelFlag,
811  RunLog& log
812  );
813 
814  virtual ~XmlElement##TypeName ();
815 
816  kkuint32 Count () const {return count;}
817  T* Value () const {return value;}
818 
819  T* TakeOwnership ();
820 
821  static
822  void WriteXML (kkuint32 count,
823  const T* d,
824  const KKStr& varName,
825  std::ostream& o
826  );
827 
828  private:
829  kkuint32 count;
830  T* value;
831  };
832  typedef XmlElement##TypeName* XmlElement##TypeName##Ptr;
833 
834 
835 
836 #define XmlElementArray2DHeader(T,TypeName,XmlElementToUse)
837  class XmlElement##TypeName: public XmlElement
838  {
839  public:
840  XmlElement##TypeName (XmlTagPtr tag,
841  XmlStream& s,
842  VolConstBool& cancelFlag,
843  RunLog& log
844  );
845 
846  virtual ~XmlElement##TypeName ();
847 
848  kkuint32 Height () const {return height;}
849  T** Value () const {return value;}
850  kkuint32 Width () const {return width;}
851 
852  T** TakeOwnership ();
853 
854  static
855  void WriteXML (kkuint32 height,
856  kkuint32 width,
857  T** const mat,
858  const KKStr& varName,
859  std::ostream& o
860  );
861 
862  private:
863  kkuint32 height;
864  T** value;
865  kkuint32 width;
866  };
867  typedef XmlElement##TypeName* XmlElement##TypeName##Ptr;
868 
869 
870 
871 
872 
873 
874 
875 
876 #define XmlElementVectorHeader(T,TypeName,ParserNextTokenMethod)
877  class XmlElement##TypeName: public XmlElement
878  {
879  public:
880  XmlElement##TypeName (XmlTagPtr tag,
881  XmlStream& s,
882  VolConstBool& cancelFlag,
883  RunLog& log
884  );
885 
886  virtual ~XmlElement##TypeName ();
887 
888  std::vector<T>* const Value () const {return value;}
889 
890  std::vector<T>* TakeOwnership ();
891 
892  static
893  void WriteXML (const std::vector<##T>& d,
894  const KKStr& varName,
895  std::ostream& o
896  );
897 
898  private:
899  std::vector<T>* value;
900  };
901  typedef XmlElement##TypeName* XmlElement##TypeName##Ptr;
902 
903 
904 
905 
910 
911 
912 
913 XmlElementArrayHeader(kkuint16, ArrayUint16, GetNextTokenUint) // XmlElementArrayUint16
914 
915 XmlElementArrayHeader(kkint32, ArrayInt32, GetNextTokenInt) // XmlElementArrayInt32
916 
917 XmlElementArrayHeader(double, ArrayDouble, GetNextTokenDouble) // XmlElementArrayDouble
918 
919 XmlElementArrayHeader(float, ArrayFloat, GetNextTokenDouble) // XmlElementArrayFloat
920 
921 
922 XmlElementArray2DHeader(float, ArrayFloat2D, XmlElementArrayFloat) // XmlElementArrayFloat2D
923 
924 
925 
926 XmlElementVectorHeader(kkint32, VectorInt32, GetNextTokenInt)
927 XmlElementVectorHeader(float, VectorFloat, GetNextTokenFloat)
928 
929 } /* KKB */
930 
931 
932 
933 #endif
virtual double ToDouble() const
Definition: XmlStream.h:666
XmlTag(const KKStr &_name, TagTypes _tagType)
Definition: XmlStream.cpp:586
XmlElementKKStrList * XmlElementKKStrListPtr
Definition: XmlStream.h:679
XmlTag * XmlTagPtr
Definition: Atom.h:31
virtual KKStr ToKKStr() const
Definition: XmlStream.h:552
virtual double ToDouble() const
Definition: XmlStream.h:315
XmlTag(std::istream &i)
XmlElementTemplate< KKStrList > XmlElementKKStrList
Definition: XmlStream.h:678
virtual ~XmlToken()
Definition: XmlStream.cpp:745
void AddAtribute(const KKStr &attributeName, const DateTime &attributeValue)
Definition: XmlStream.cpp:649
XmlAttributeConst * XmlAttributeConstPtr
Definition: XmlStream.h:132
void AddAtribute(const KKStr &attributeName, bool attributeValue)
Definition: XmlStream.cpp:611
XmlTag const XmlTagConst
Definition: Atom.h:33
XmlFactory * FactoryLookUp(const KKStr &className) const
Definition: XmlStream.cpp:979
KKStrConstPtr AttributeValue(const char *attributeName)
Definition: XmlStream.cpp:818
__int32 kkint32
Definition: KKBaseTypes.h:88
XmlAttribute const XmlAttributeConst
Definition: XmlStream.h:131
TagTypes TagType() const
Definition: XmlStream.h:194
XmlElementKKStr(XmlTagPtr tag, XmlStream &s, VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.h:656
void RegisterFactory(XmlFactory *factory)
Definition: XmlStream.cpp:959
XmlStream * XmlStreamPtr
Definition: XmlStream.h:49
virtual float ToFloat() const
Definition: XmlStream.h:518
XmlElementArrayFloat2DVarying(XmlTagPtr tag, XmlStream &s, VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:1283
virtual KKStr ToKKStr() const
Definition: XmlStream.h:314
bool Value() const
Definition: XmlStream.cpp:1028
void Add(const KKStr &key, float v)
Definition: XmlStream.cpp:1212
#define XmlElementVectorHeader(T, TypeName, ParserNextTokenMethod)
Definition: XmlStream.h:876
XmlElement(XmlTagPtr _nameTag, XmlStream &s, RunLog &log)
Definition: XmlStream.cpp:758
const KKStr & AttributeValueKKStr(const KKStr &name) const
Definition: XmlStream.cpp:330
virtual ~XmlElementUnKnown()
Definition: XmlStream.cpp:1068
KKStrConstPtr AttributeValueByIndex(kkuint32 index) const
Definition: XmlStream.cpp:664
XmlFactoryManager(const KKStr &_name)
Definition: XmlStream.cpp:939
XmlAttribute * XmlAttributePtr
Definition: XmlStream.h:130
const KKStr & Name() const
Definition: XmlStream.h:122
virtual float ToFloat() const
Definition: XmlStream.h:316
const KKStr & AttributeValueKKStr(const KKStr &name) const
Definition: XmlStream.cpp:688
KKStrConstPtr AttributeValueByName(const KKStr &name) const
Definition: XmlStream.cpp:301
T *const Value() const
Definition: XmlStream.h:441
XmlElementBool * XmlElementBoolPtr
Definition: XmlStream.h:524
XmlElement * XmlElementPtr
Definition: XmlStream.h:286
XmlElementTemplate< KKStrListIndexed > XmlElementKKStrListIndexed
Definition: XmlStream.h:682
unsigned __int16 kkuint16
16 bit unsigned integer.
Definition: KKBaseTypes.h:86
DateTime AttributeValueDateTime(const KKStr &attributeName) const
Definition: XmlStream.cpp:682
void AddAtribute(const KKStr &attributeName, kkint64 attributeValue)
Definition: XmlStream.cpp:629
XmlContent * XmlContentPtr
Definition: XmlStream.h:24
virtual double ToDouble() const
Definition: XmlStream.h:553
virtual KKStr ToKKStr() const
Definition: XmlStream.h:516
XmlElementUnKnown(XmlTagPtr tag, XmlStream &s, VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:1051
kkint32 AttributeValueInt32(const KKStr &name) const
Definition: XmlStream.cpp:341
const KKStr & Value() const
Definition: XmlStream.h:123
virtual TokenTypes TokenType()
Definition: XmlStream.h:336
void Add(const KKStr &key, kkint32 v)
Definition: XmlStream.cpp:1203
virtual bool ToBool() const
Definition: XmlStream.h:664
static void RegisterFactory(XmlFactory *factory)
Definition: XmlStream.cpp:897
std::deque< XmlTokenPtr > * TakeOwnership()
Definition: XmlStream.cpp:1080
XmlElementVectorKKStr * XmlElementVectorKKStrPtr
Definition: XmlStream.h:675
static void WriteXML(const T &t, const KKStr &varName, std::ostream &o)
Definition: XmlStream.h:451
static void WriteXML(const bool b, const KKStr &varName, std::ostream &o)
Definition: XmlStream.cpp:1035
KKStr ToString() const
Definition: XmlStream.cpp:694
const KKStr & Name() const
Definition: XmlStream.h:193
virtual kkint32 ToInt32() const
Definition: XmlStream.h:555
XmlElementDateTime * XmlElementDateTimePtr
Definition: XmlStream.h:560
void AddAttribute(const KKStr &name, const KKStr &value)
Definition: XmlStream.cpp:366
virtual const KKStr & SectionName() const
Definition: XmlStream.h:265
XmlToken * XmlTokenPtr
Definition: XmlStream.h:18
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
XmlFactory(const KKStr &_clasName)
Definition: XmlStream.cpp:931
__int64 kkint64
Definition: KKBaseTypes.h:90
XmlElementBool(XmlTagPtr tag, XmlStream &s, VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:998
void Add(const KKStr &key, bool v)
Definition: XmlStream.cpp:1232
XmlElementKeyValuePairs(XmlTagPtr tag, XmlStream &s, VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:1141
virtual kkint32 ToInt32() const
Definition: XmlStream.h:668
virtual float ToFloat() const
Definition: XmlStream.h:554
KKStrConstPtr AttributeNameByIndex(kkuint32 index) const
Definition: XmlStream.cpp:320
virtual kkint32 ToInt32() const
Definition: XmlStream.h:317
KKStrConstPtr AttributeValueByName(const KKStr &name) const
Definition: XmlStream.cpp:658
void AddAtribute(const KKStr &attributeName, kkint32 attributeValue)
Definition: XmlStream.cpp:620
KKTHread * KKTHreadPtr
virtual bool ToBool() const
Definition: XmlStream.h:313
void Add(const KKStr &key, double v)
Definition: XmlStream.cpp:1222
const XmlAttributeList & Attributes() const
Definition: XmlStream.h:198
std::vector< std::pair< KKStr, KKStr > > * Value() const
Definition: XmlStream.h:586
void Add(const KKStr &key, const KKStr &v)
Definition: XmlStream.cpp:1193
kkint32 AttributeCount() const
Definition: XmlStream.h:196
kkint32 AttributeValueInt32(const KKStr &attributeName) const
Definition: XmlStream.cpp:676
KKStrPtr TakeOwnership()
Definition: XmlStream.cpp:845
KKStr(const KKStr &str)
Copy Constructor.
Definition: KKStr.cpp:561
XmlElement * XmlElementPtr
Definition: XmlStream.h:21
void AddAtribute(const KKStr &attributeName, const KKStr &attributeValue)
Definition: XmlStream.cpp:602
virtual XmlAttributePtr PopFromBack()
Definition: XmlStream.cpp:264
virtual kkint32 ToInt32() const
Definition: XmlStream.h:519
XmlAttributeList * XmlAttributeListPtr
Definition: XmlStream.h:170
XmlStream * XmlStreamPtr
Definition: Atom.h:29
#define XmlElementBuiltInTypeHeader(T, TypeName)
Definition: XmlStream.h:768
Manages the reading and writing of objects in a simple XML format. For a class to be supported by Xml...
Definition: XmlStream.h:46
virtual bool ToBool() const
Definition: XmlStream.h:551
static void WriteXML(kkuint32 height, const kkint32 *widths, float **const mat, const KKStr &varName, std::ostream &o)
Definition: XmlStream.cpp:1374
virtual bool ToBool() const
Definition: XmlStream.h:515
#define XmlElementArrayHeader(T, TypeName, ParserNextTokenMethod)
Definition: XmlStream.h:804
XmlElement derived class that will be used when there is no Factory defined for the element...
Definition: XmlStream.h:471
XmlTag * XmlTagPtr
Definition: XmlStream.h:175
static XmlFactory * FactoryLookUp(const KKStr &className)
Definition: XmlStream.cpp:879
virtual float ToFloat() const
Definition: XmlStream.h:667
XmlTokenizer * XmlTokenizerPtr
Definition: XmlTokenizer.h:117
#define XmlElementArray2DHeader(T, TypeName, XmlElementToUse)
Definition: XmlStream.h:836
virtual ~XmlElementBool()
Definition: XmlStream.cpp:1023
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
virtual const KKStr & ClassName() const
Definition: XmlStream.h:387
KKStrConstPtr AttributeValue(const KKStr &attributeName)
Definition: XmlStream.cpp:809
virtual ~XmlStream()
Definition: XmlStream.cpp:56
static const KKStr & EmptyStr()
Static method that returns an Empty String.
Definition: KKStr.cpp:3453
XmlFactory const * XmlFactoryConstPtr
summary>To be used for classes that implement default constructor, ReadXML, and WriteXML.
Definition: XmlStream.h:411
XmlFactory * XmlFactoryPtr
Definition: XmlStream.h:27
virtual ~XmlContent()
Definition: XmlStream.cpp:837
virtual const KKStr & VarName() const
Definition: XmlStream.cpp:794
XmlElementDateTime(XmlTagPtr tag, XmlStream &s, VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:1096
KKStrConstPtr AttributeValueByIndex(kkuint32 index) const
Definition: XmlStream.cpp:311
XmlTagConstPtr NameTag() const
Definition: XmlStream.h:299
KKStr YYYY_MM_DD_HH_MM_SS() const
Definition: DateTime.cpp:1216
kkuint32 ToDays() const
Definition: DateTime.cpp:1100
XmlElementUnKnown * XmlElementUnKnownPtr
Definition: XmlStream.h:490
XmlAttributeList(bool _owner)
Definition: XmlStream.cpp:235
XmlElementArrayFloat2DVarying * XmlElementArrayFloat2DVaryingPtr
Definition: XmlStream.h:647
XmlAttributePtr LookUpByName(const KKStr &name) const
Definition: XmlStream.cpp:375
XmlStream(const KKStr &_fileName, RunLog &_log)
Definition: XmlStream.cpp:41
XmlElementKeyValuePairs * XmlElementKeyValuePairsPtr
Definition: XmlStream.h:605
XmlElementTemplate(XmlTagPtr tag, XmlStream &s, VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.h:422
virtual XmlElementPtr ManufatureXmlElement(XmlTagPtr tag, XmlStream &s, VolConstBool &cancelFlag, RunLog &log)=0
void RegisterFactory(XmlFactoryPtr factory)
Registers a Factory at the current hierarchy that is being processed.
Definition: XmlStream.cpp:67
std::vector< std::pair< KKStr, KKStr > > * TakeOwnership()
Definition: XmlStream.cpp:1185
virtual const KKStr & SectionName() const
Definition: XmlStream.cpp:785
virtual double ToDouble() const
Definition: XmlStream.h:517
KKStr NameTagStr() const
Definition: XmlStream.cpp:775
virtual TokenTypes TokenType()
Definition: XmlStream.h:305
XmlFactoryManager * XmlFactoryManagerPtr
Definition: XmlStream.h:30
virtual void PushOnBack(XmlAttributePtr a)
Definition: XmlStream.cpp:250
XmlElement(const KKStr &sectionName, XmlTag::TagTypes tagType)
Definition: XmlStream.cpp:750
static XmlFactoryManagerPtr globalXmlFactoryManager
Definition: XmlStream.h:402
virtual KKStr ToKKStr() const
Definition: XmlStream.h:665
XmlElementKKStrListIndexed * XmlElementKKStrListIndexedPtr
Definition: XmlStream.h:683
kkuint64 Seconds() const
Definition: DateTime.cpp:1092
static void WriteXml(const KKStr &s, std::ostream &o)
Definition: XmlStream.cpp:853
virtual ~XmlElement()
Definition: XmlStream.cpp:767
XmlContent(KKStrPtr _content)
Definition: XmlStream.cpp:829
XmlContent * XmlContentPtr
Definition: XmlStream.h:331
XmlElementKKStr * XmlElementKKStrPtr
Definition: XmlStream.h:670
void WriteXML(std::ostream &o)
Definition: XmlStream.cpp:723
KKStrPtr const Content() const
Definition: XmlStream.h:338
kkuint32 * Widths() const
Definition: XmlStream.h:626
Used for logging messages.
Definition: RunLog.h:49
XmlToken * XmlTokenPtr
Definition: XmlStream.h:255
static void FinalCleanUp()
Definition: XmlStream.cpp:921
XmlTag(const KKStrConstPtr tagStr)
Definition: XmlStream.cpp:543
XmlElementTemplate< VectorKKStr > XmlElementVectorKKStr
Definition: XmlStream.h:674
static void WriteXML(const DateTime &d, const KKStr &varName, std::ostream &o)
Definition: XmlStream.cpp:1113
virtual TokenTypes TokenType()=0
DateTime Value() const
Definition: XmlStream.h:543
virtual XmlTokenPtr GetNextToken(VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:116
virtual XmlAttributePtr PopFromFromt()
Definition: XmlStream.cpp:273
std::deque< XmlTokenPtr > * Value() const
Definition: XmlStream.h:482
XmlElementKeyValuePairs()
Used to construct an instance that will be written out to a XML file.
Definition: XmlStream.cpp:1134
virtual void PushOnFront(XmlAttributePtr a)
Definition: XmlStream.cpp:257
virtual const KKStr & VarName() const
Definition: XmlStream.h:269
XmlFactoryPtr XmlElementKKStrFactoryInstance()
Definition: XmlStream.cpp:1415
virtual XmlContentPtr GetNextContent(RunLog &log)
Definition: XmlStream.cpp:210
void Add(const KKStr &key, const KKB::DateTime &v)
Definition: XmlStream.cpp:1243
XmlFactoryPtr XmlElementUnKnownFactoryInstance()
Definition: XmlStream.cpp:1090
XmlStream(XmlTokenizerPtr _tokenStream)
Definition: XmlStream.cpp:29
XmlAttributeList(const XmlAttributeList &attributes)
Definition: XmlStream.cpp:241
KKStrConstPtr AttributeNameByIndex(kkuint32 index) const
Definition: XmlStream.cpp:670
~XmlFactoryManager()
summary>Give the FactoryManager instance ownership of this factory; the name of the factory must be u...
Definition: XmlStream.cpp:946
void AddAtribute(const KKStr &attributeName, double attributeValue)
Definition: XmlStream.cpp:638
void WriteXML(const KKStr &varName, std::ostream &o)
Definition: XmlStream.cpp:1252
DateTime AttributeValueDateTime(const KKStr &name) const
Definition: XmlStream.cpp:352
XmlAttribute(const KKStr &_name, const KKStr &_value)
Definition: XmlStream.h:115
volatile const bool VolConstBool
Definition: KKBaseTypes.h:163
virtual ~XmlTag()
Definition: XmlStream.cpp:596