Choreonoid  1.1
YamlReader.h
[詳解]
1 
5 #ifndef CNOID_UTIL_YAML_READER_H_INCLUDED
6 #define CNOID_UTIL_YAML_READER_H_INCLUDED
7 
8 #include "YamlNodes.h"
9 #include "exportdecl.h"
10 
11 namespace cnoid {
12 
13  class YamlReaderImpl;
14 
16  {
17  class MappingFactoryBase {
18  public:
19  virtual YamlMapping* create(int line, int column) = 0;
20  };
21 
22  template <class MappingType> class MappingFactory : public MappingFactoryBase {
23  public:
24  virtual YamlMapping* create(int line, int column) { return new MappingType(line, column); }
25  };
26 
27  public:
28 
29  YamlReader();
30  ~YamlReader();
31 
32  template <class TMapping> inline void setMappingClass() {
33  setMappingFactory(new MappingFactory<TMapping>());
34  }
35 
36  void expectRegularMultiSequence();
37 
38  bool load(const std::string& filename);
39  bool load_string(const std::string& yamlstring);
40 
41  int numDocuments();
42  YamlNode* document(int index = 0);
43 
44  void clearDocuments();
45 
46  const std::string& errorMessage();
47 
48  private:
49 
50  friend class YamlReaderImpl;
51 
52  YamlReaderImpl* impl;
53 
54  void setMappingFactory(MappingFactoryBase* factory);
55  };
56 }
57 
58 #endif
void setMappingClass()
Definition: YamlReader.h:32
Definition: YamlNodes.h:37
Definition: YamlNodes.h:212
Definition: YamlReader.h:15
#define CNOID_EXPORT
Definition: Util/exportdecl.h:13