Reader.h
Go to the documentation of this file.
1 #ifndef _utl_Reader_h_
2 #define _utl_Reader_h_
3 
4 #include <utl/Branch.h>
5 #include <sstream>
6 
7 
8 namespace utl {
9 
10  class ReaderStringInput;
11  class ReaderErrorReporter;
12 
13 
25  class Reader {
26 
27  public:
32  };
33 
35  Reader(const std::string& name, const EValidationType validationType = Reader::eNONE);
36 
38  Reader(const ReaderStringInput& inputString, const EValidationType validationType = Reader::eNONE);
39 
40  Reader(Branch& branch);
41 
42  std::string GetUri() const;
43 
45  Branch GetTopBranch() const { return fTopBranch; }
46 
47  private:
48  Reader(const Reader& re); // not implemented to prevent copying
49  Reader& operator=(const Reader& re); // not implemented to prevent copying
50 
51  void Initialize(); // all ctors have to call this first
52  static void Terminate(); // atexit calls this
53 
54  enum EInputType {
55  eFromFile = 0, // take XML input from file
56  eFromMemBuf // take XML input from memory
57  };
58 
59  static Branch Parse(const std::string& input,
60  const EValidationType validationType,
61  const EInputType inputType);
62 
63  // Branch at the top of the document tree.
65 
66  // helper function for dumping out the XML tree (recursive), kept here just in case.
67  // A function like this belongs in the BasicConstBranch class, not here.
68  // void DumpMe(Branch& b, const int indent = 2, const int indentIncrement = 2) const;
69 
71  static bool fgInitialized;
72 
73  };
74 
75 
89 
90  public:
91  ReaderStringInput() = default;
92 
93  ReaderStringInput(const std::string& inputString)
94  { fInputString = inputString; }
95 
96  ReaderStringInput(const std::ostringstream& inputStream)
97  { fInputString = inputStream.str(); }
98 
99  const std::string& GetInputString() const { return fInputString; }
100 
101  private:
102  std::string fInputString;
103 
104  };
105 
106 }
107 
108 
109 #endif
std::string GetUri() const
Definition: Reader.cc:89
EValidationType
Definition: Reader.h:28
ReaderStringInput(const std::ostringstream &inputStream)
Definition: Reader.h:96
Branch GetTopBranch() const
Get the top Branch (represents same entity as document node)
Definition: Reader.h:45
Utility for parsing XML files.
Definition: Reader.h:25
Class representing a document branch.
Definition: Branch.h:107
static bool fgInitialized
Definition: Reader.h:71
This just defines a type which holds some character data to be parsed by the Reader.
Definition: Reader.h:88
static void Terminate()
Definition: Reader.cc:79
ReaderStringInput(const std::string &inputString)
Definition: Reader.h:93
Reader & operator=(const Reader &re)
void Initialize()
Definition: Reader.cc:61
Reader(const std::string &name, const EValidationType validationType=Reader::eNONE)
Constructor with validation options.
Definition: Reader.cc:34
std::string fInputString
Definition: Reader.h:102
Branch fTopBranch
Definition: Reader.h:64
static ReaderErrorReporter * fgErrReporter
Definition: Reader.h:70
static Branch Parse(const std::string &input, const EValidationType validationType, const EInputType inputType)
Definition: Reader.cc:106
Reports errors encountered during XML parsing.
const std::string & GetInputString() const
Definition: Reader.h:99

, generated on Tue Sep 26 2023.