Choreonoid  1.8
ValueTree.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_UTIL_VALUE_TREE_H
6 #define CNOID_UTIL_VALUE_TREE_H
7 
8 #include "Referenced.h"
9 #include <map>
10 #include <vector>
11 #include <string>
12 #include <initializer_list>
13 #include "exportdecl.h"
14 
15 namespace cnoid {
16 
17 class YAMLReaderImpl;
18 class ValueNode;
19 class ScalarNode;
20 class Mapping;
21 class Listing;
22 
23 #ifndef CNOID_BACKWARD_COMPATIBILITY
25 #else
26 enum StringStyle { PLAIN_STRING, YAML_PLAIN_STRING = PLAIN_STRING,
27  SINGLE_QUOTED, YAML_SINGLE_QUOTED = SINGLE_QUOTED,
28  DOUBLE_QUOTED, YAML_DOUBLE_QUOTED = DOUBLE_QUOTED,
29  LITERAL_STRING, YAML_LITERAL = LITERAL_STRING,
30  FOLDED_STRING, YAML_FOLDED = FOLDED_STRING
31 };
32 #endif
33 
34 class CNOID_EXPORT ValueNode : public Referenced
35 {
36  struct Initializer {
37  Initializer();
38  };
39  static Initializer initializer;
40 
41 public:
42  virtual ValueNode* clone() const;
43 
44  enum TypeBit {
45  INVALID_NODE = 0,
46  SCALAR = 1,
47  MAPPING = 2,
48  LISTING = 4,
49  INSERT_LF = 8,
50  APPEND_LF = 16,
51  FORCED_RADIAN_MODE = 32
52  };
53 
54  bool isValid() const { return typeBits; }
55  explicit operator bool() const { return isValid(); }
56 
57  TypeBit LFType() const { return (TypeBit)(typeBits & (INSERT_LF | APPEND_LF)); }
58  TypeBit nodeType() const { return (TypeBit)(typeBits & 7); }
59 
60  int toInt() const;
61  double toDouble() const;
62  float toFloat() const;
63  bool toBool() const;
64  [[deprecated("Check isForcedRadianMode() of the top node.")]]
65  double toAngle() const;
66 
67  bool isScalar() const { return typeBits & SCALAR; }
68  bool isString() const { return typeBits & SCALAR; }
69  bool isCollection() const { return typeBits & (MAPPING | LISTING); }
70 
71  const std::string& toString() const;
72 
73  operator const std::string& () const {
74  return toString();
75  }
76 
82  bool isForcedRadianMode() const { return typeBits & FORCED_RADIAN_MODE; }
83  void setForcedRadianMode(bool on = true) { typeBits |= FORCED_RADIAN_MODE; }
84  [[deprecated("Use 'isForcedRadianMode' to determine the angle unit.")]]
85  bool isDegreeMode() const { return !isForcedRadianMode(); }
86  [[deprecated("Use ''setForcedRadianMode' to specify the angle unit.")]]
87  void setDegreeMode() { setForcedRadianMode(false); }
88 
89  template<typename T> T to() const;
90 
91  bool isMapping() const { return typeBits & MAPPING; }
92  const Mapping* toMapping() const;
93  Mapping* toMapping();
94 
95  bool isListing() const { return typeBits & LISTING; }
96  const Listing* toListing() const;
97  Listing* toListing();
98 
99 #ifdef CNOID_BACKWARD_COMPATIBILITY
100  bool isSequence() const { return typeBits & LISTING; }
101  const Listing* toSequence() const { return toListing(); }
102  Listing* toSequence() { return toListing(); }
103 #endif
104 
105  bool read(int &out_value) const;
106  bool read(double &out_value) const;
107  bool read(float &out_value) const;
108  bool read(bool &out_value) const;
109  bool read(std::string &out_value) const;
110 
111  bool hasLineInfo() const { return (line_ >= 0); }
112  int line() const { return line_ + 1; }
113  int column() const { return column_ + 1; }
114 
115  void throwException(const std::string& message) const;
116 
120  class CNOID_EXPORT Exception {
121 public:
122  Exception();
123  virtual ~Exception();
124  int line() const { return line_; }
125  int column() const { return column_; }
126  std::string message() const;
127  void setPosition(int line, int column) {
128  line_ = line;
129  column_ = column;
130  }
131  void setMessage(const std::string& m){
132  message_ = m;
133  }
134 private:
135  int line_;
136  int column_;
137  std::string message_;
138  };
139 
141  public:
142  const std::string& key() { return key_; }
143  void setKey(const std::string& key) { key_ = key; }
144  private:
145  std::string key_;
146  };
147 
148  class EmptyKeyException : public Exception {
149  };
150 
151  class NotScalarException : public Exception {
152  };
153 
155  };
156 
158  };
159 
161  };
162 
163  class SyntaxException : public Exception {
164  };
165 
167  };
168 
169  class FileException : public Exception {
170  };
171 
173  };
174 
175  // This function is only used by YAMLWriter
176  int indexInMapping() const { return indexInMapping_; }
177  void setAsHeaderInMapping(int priority = 1) { indexInMapping_ = -priority; }
178 
179 protected:
180 
181  ValueNode() { }
182  ValueNode(TypeBit type) : typeBits(type), line_(-1), column_(-1) { }
183 
184  virtual ~ValueNode() { }
185 
186  void throwNotScalrException() const;
187  void throwNotMappingException() const;
188  void throwNotListingException() const;
189 
190  int typeBits;
191 
192 private:
193  ValueNode(const ValueNode& org);
194  ValueNode& operator=(const ValueNode&);
195 
196  int line_;
197  int column_;
198 
200  int indexInMapping_;
201 
202  friend class YAMLReaderImpl;
203  friend class ScalarNode;
204  friend class Mapping;
205  friend class Listing;
206 };
207 
208 template<> inline double ValueNode::to<double>() const { return toDouble(); }
209 template<> inline float ValueNode::to<float>() const { return toFloat(); }
210 template<> inline int ValueNode::to<int>() const { return toInt(); }
211 template<> inline std::string ValueNode::to<std::string>() const { return toString(); }
212 
214 
215 
216 class CNOID_EXPORT ScalarNode : public ValueNode
217 {
218 public:
219  ScalarNode(const std::string& value, StringStyle stringStyle = PLAIN_STRING);
220  ScalarNode(int value);
221 
222  virtual ValueNode* clone() const;
223 
224  const std::string& stringValue() const { return stringValue_; }
225  StringStyle stringStyle() const { return stringStyle_; }
226 
227 private:
228  ScalarNode(const char* text, size_t length);
229  ScalarNode(const char* text, size_t length, StringStyle stringStyle);
230  ScalarNode(const ScalarNode& org);
231 
232  std::string stringValue_;
233  StringStyle stringStyle_;
234 
235  friend class YAMLReaderImpl;
236  friend class ValueNode;
237  friend class Mapping;
238  friend class Listing;
239 };
240 
241 
242 inline const std::string& ValueNode::toString() const
243 {
244  if(!isScalar()){
246  }
247  return static_cast<const ScalarNode* const>(this)->stringValue_;
248 }
249 
250 
251 class CNOID_EXPORT Mapping : public ValueNode
252 {
253  typedef std::map<std::string, ValueNodePtr> Container;
254 
255 public:
256 
257  typedef Container::iterator iterator;
258  typedef Container::const_iterator const_iterator;
259 
260  Mapping();
261  Mapping(int line, int column);
262  virtual ~Mapping();
263 
264  virtual ValueNode* clone() const;
265  virtual Mapping* cloneMapping() const;
266 
267  bool empty() const { return values.empty(); }
268  int size() const { return static_cast<int>(values.size()); }
269  void clear();
270 
271  void setFlowStyle(bool isFlowStyle = true) { isFlowStyle_ = isFlowStyle; }
272  bool isFlowStyle() const { return isFlowStyle_; }
273 
274  void setFloatingNumberFormat(const char* format);
275  const char* floatingNumberFormat() { return floatingNumberFormat_; }
276 
277  [[deprecated("Use Mapping::setFloatingNumberFormat")]]
278  void setDoubleFormat(const char* format) { setFloatingNumberFormat(format); }
279  [[deprecated("Use Mapping::floatingNumberFormat")]]
280  const char* doubleFormat() { return floatingNumberFormat(); }
281 
282  void setKeyQuoteStyle(StringStyle style);
283 
284  ValueNode* find(const std::string& key) const;
285  ValueNode* find(std::initializer_list<const char*> keys) const;
286  Mapping* findMapping(const std::string& key) const;
287  Mapping* findMapping(std::initializer_list<const char*> keys) const;
288  Listing* findListing(const std::string& key) const;
289  Listing* findListing(std::initializer_list<const char*> keys) const;
290 
291  ValueNodePtr extract(const std::string& key);
292  ValueNodePtr extract(std::initializer_list<const char*> keys);
293 
294  bool extract(const std::string& key, double& out_value);
295  bool extract(const std::string& key, std::string& out_value);
296 
297  ValueNode& get(const std::string& key) const;
298 
299  ValueNode& operator[](const std::string& key) const {
300  return get(key);
301  }
302 
303  void insert(const std::string& key, ValueNode* node);
304 
305  void insert(const Mapping* other);
306 
307  Mapping* openMapping(const std::string& key) {
308  return openMapping_(key, false);
309  }
310 
311  Mapping* openFlowStyleMapping(const std::string& key) {
312  return openFlowStyleMapping_(key, false);
313  }
314 
315  Mapping* createMapping(const std::string& key) {
316  return openMapping_(key, true);
317  }
318 
319  Mapping* createFlowStyleMapping(const std::string& key) {
320  return openFlowStyleMapping_(key, true);
321  }
322 
323  Listing* openListing(const std::string& key) {
324  return openListing_(key, false);
325  }
326 
327  Listing* openFlowStyleListing(const std::string& key){
328  return openFlowStyleListing_(key, false);
329  }
330 
331  Listing* createListing(const std::string& key){
332  return openListing_(key, true);
333  }
334 
335  Listing* createFlowStyleListing(const std::string& key){
336  return openFlowStyleListing_(key, true);
337  }
338 
339  bool remove(const std::string& key);
340 
341  bool read(const std::string& key, std::string& out_value) const;
342  bool read(const std::string& key, bool& out_value) const;
343  bool read(const std::string& key, int& out_value) const;
344  bool read(const std::string& key, double& out_value) const;
345  bool read(const std::string& key, float& out_value) const;
346 
347  template<class T>
348  bool read(std::initializer_list<const char*> keys, T& out_value) const {
349  for(auto& key : keys){
350  if(this->read(key, out_value)){
351  return true;
352  }
353  }
354  return false;
355  }
356 
357  bool readAngle(const std::string& key, double& out_angle, const ValueNode* unitAttrNode = nullptr) const;
358  bool readAngle(const std::string& key, float& out_angle, const ValueNode* unitAttrNode = nullptr) const;
359  bool readAngle(std::initializer_list<const char*> keys, double& out_angle, const ValueNode* unitAttrNode = nullptr) const;
360  bool readAngle(std::initializer_list<const char*> keys, float& out_angle, const ValueNode* unitAttrNode = nullptr) const;
361 
362  template <class T> T get(const std::string& key) const {
363  T value;
364  if(read(key, value)){
365  return value;
366  } else {
367  throwKeyNotFoundException(key);
368  return value;
369  }
370  }
371 
372  template <class T>
373  T get(const std::string& key, const T& defaultValue) const {
374  T value;
375  if(read(key, value)){
376  return value;
377  } else {
378  return defaultValue;
379  }
380  }
381 
382  std::string get(const std::string& key, const char* defaultValue) const {
383  std::string value;
384  if(read(key, value)){
385  return value;
386  } else {
387  return defaultValue;
388  }
389  }
390 
391  template<class T>
392  T get(std::initializer_list<const char*> keys, const T& defaultValue) const {
393  T value;
394  if(read(keys, value)){
395  return value;
396  } else {
397  return defaultValue;
398  }
399  }
400 
401  void write(const std::string& key, const std::string& value, StringStyle stringStyle = PLAIN_STRING);
402  void write(const std::string& key, const char* value, StringStyle stringStyle = PLAIN_STRING){
403  write(key, std::string(value), stringStyle);
404  }
405 
406  void write(const std::string& key, bool value);
407  void write(const std::string& key, int value);
408  void write(const std::string& key, double value);
409  void writePath(const std::string &key, const std::string& value);
410 
411  template<class ArrayType> void writeAsListing(const std::string& key, const ArrayType& container);
412 
413  typedef enum { READ_MODE, WRITE_MODE } AssignMode;
414 
415  void setAssignMode(AssignMode mode) { this->mode = mode; }
416 
417  template <class T>
418  void assign(const std::string& key, T& io_value, const T& defaultValue){
419  switch(mode){
420  case READ_MODE:
421  if(!read(key, io_value)){
422  io_value = defaultValue;
423  }
424  break;
425  case WRITE_MODE:
426  write(key, io_value);
427  break;
428  }
429  }
430 
431  iterator begin() { return values.begin(); }
432  iterator end() { return values.end(); }
433  const_iterator begin() const { return values.begin(); }
434  const_iterator end() const { return values.end(); }
435 
436  void throwKeyNotFoundException(const std::string& key) const;
437 
438  StringStyle keyStringStyle() const { return keyStringStyle_; }
439 
441  template <class T> T read(const std::string& key) const { return get<T>(key); }
442 
443 #ifdef CNOID_BACKWARD_COMPATIBILITY
444  Listing* findSequence(const std::string& key) const { return findListing(key); }
445  Listing* openSequence(const std::string& key) { return openListing(key); }
446  Listing* openFlowStyleSequence(const std::string& key){ return openFlowStyleListing(key); }
447  Listing* createSequence(const std::string& key){ return createListing(key); }
448  Listing* createFlowStyleSequence(const std::string& key){ return createFlowStyleListing(key); }
449 #endif
450 
451 private:
452 
453  Mapping(const Mapping& org);
454  Mapping& operator=(const Mapping&);
455 
456  Mapping* openMapping_(const std::string& key, bool doOverwrite);
457  Mapping* openFlowStyleMapping_(const std::string& key, bool doOverwrite);
458  Listing* openListing_(const std::string& key, bool doOverwrite);
459  Listing* openFlowStyleListing_(const std::string& key, bool doOverwrite);
460 
461  inline void insertSub(const std::string& key, ValueNode* node);
462 
463  void writeSub(const std::string &key, const char* text, size_t length, StringStyle stringStyle);
464 
465  Container values;
466  AssignMode mode;
467  int indexCounter;
468  const char* floatingNumberFormat_;
469  bool isFlowStyle_;
470  StringStyle keyStringStyle_;
471 
472  friend class Listing;
473  friend class YAMLReaderImpl;
474 };
475 
477 
478 
484 class CNOID_EXPORT Listing : public ValueNode
485 {
486  typedef std::vector<ValueNodePtr> Container;
487 
488 public:
489 
490  Listing();
491  Listing(int size);
492  ~Listing();
493 
494  virtual ValueNode* clone() const;
495 
496  typedef Container::iterator iterator;
497  typedef Container::const_iterator const_iterator;
498 
499  bool empty() const { return values.empty(); }
500  int size() const { return static_cast<int>(values.size()); }
501  void clear();
502  void reserve(int size);
503 
504  void setFlowStyle(bool isFlowStyle = true) { isFlowStyle_ = isFlowStyle; }
505  bool isFlowStyle() const { return isFlowStyle_; }
506 
507  void setFloatingNumberFormat(const char* format);
508  const char* floatingNumberFormat() { return floatingNumberFormat_; }
509 
510  [[deprecated("Use Mapping::setFloatingNumberFormat")]]
511  void setDoubleFormat(const char* format) { setFloatingNumberFormat(format); }
512  [[deprecated("Use Mapping::floatingNumberFormat")]]
513  const char* doubleFormat() { return floatingNumberFormat(); }
514 
515  ValueNode* front() const {
516  return values.front();
517  }
518 
519  ValueNode* back() const {
520  return values.back();
521  }
522 
523  ValueNode* at(int i) const {
524  return values[i];
525  }
526 
530  ValueNode& get(int i) const {
531  return *values[i];
532  }
533 
534  void write(int i, int value);
535  void write(int i, const std::string& value, StringStyle stringStyle = PLAIN_STRING);
536 
540  ValueNode& operator[](int i) const {
541  return *values[i];
542  }
543 
545  //MappingPtr extractMapping(const std::string& key) const;
546 
547  Mapping* newMapping();
548 
549  void append(ValueNode* node) {
550  values.push_back(node);
551  }
552 
553  void insert(int index, ValueNode* node);
554 
555  void append(int value);
556 
562  void append(int value, int maxColumns, int numValues = 0) {
563  insertLF(maxColumns, numValues);
564  append(value);
565  }
566 
567  void append(size_t value);
568  void append(double value);
569 
575  void append(double value, int maxColumns, int numValues = 0) {
576  insertLF(maxColumns, numValues);
577  append(value);
578  }
579 
580  void append(const std::string& value, StringStyle stringStyle = PLAIN_STRING);
581 
587  void append(const std::string& value, int maxColumns, int numValues = 0, StringStyle stringStyle = PLAIN_STRING){
588  insertLF(maxColumns, numValues);
589  append(value, stringStyle);
590  }
591 
592  void appendLF();
593 
594  iterator begin() { return values.begin(); }
595  iterator end() { return values.end(); }
596  const_iterator begin() const { return values.begin(); }
597  const_iterator end() const { return values.end(); };
598 
599 private:
600 
601  Listing(int line, int column);
602  Listing(int line, int column, int reservedSize);
603 
604  Listing(const Listing& org);
605  Listing& operator=(const Listing&);
606 
607  void insertLF(int maxColumns, int numValues);
608 
609  Container values;
610  const char* floatingNumberFormat_;
611  bool isFlowStyle_;
612  bool doInsertLFBeforeNextElement;
613 
614  friend class Mapping;
615  friend class YAMLReaderImpl;
616 };
617 
618 
619 template<class ArrayType>
620 void Mapping::writeAsListing(const std::string& key, const ArrayType& container)
621 {
622  auto listing = createFlowStyleListing(key);
623  for(auto& value : container){
624  listing->append(value);
625  }
626 }
627 
628 
630 
631 #ifdef CNOID_BACKWARD_COMPATIBILITY
632 typedef ValueNode YamlNode;
633 typedef ValueNodePtr YamlNodePtr;
634 typedef ScalarNode YamlScalar;
635 typedef Mapping YamlMapping;
636 typedef MappingPtr YamlMappingPtr;
637 typedef Listing YamlSequence;
638 typedef ListingPtr YamlSequencePtr;
639 typedef Listing Sequence;
640 typedef ListingPtr SequencePtr;
641 #endif
642 }
643 
644 #endif
cnoid::Listing::isFlowStyle
bool isFlowStyle() const
Definition: ValueTree.h:505
cnoid::LISTING
@ LISTING
Definition: YAMLWriter.cpp:18
cnoid::ValueNode::ValueNode
ValueNode(TypeBit type)
Definition: ValueTree.h:182
cnoid::Mapping::begin
iterator begin()
Definition: ValueTree.h:431
cnoid::ValueNode::isValid
bool isValid() const
Definition: ValueTree.h:54
Referenced.h
cnoid::ValueNode::~ValueNode
virtual ~ValueNode()
Definition: ValueTree.h:184
cnoid::ValueNode::isScalar
bool isScalar() const
Definition: ValueTree.h:67
cnoid::ValueNode::Exception::column
int column() const
Definition: ValueTree.h:125
cnoid::Mapping
Definition: ValueTree.h:251
cnoid::Mapping::get
T get(const std::string &key) const
Definition: ValueTree.h:362
cnoid::Mapping::openListing
Listing * openListing(const std::string &key)
Definition: ValueTree.h:323
cnoid::Mapping::setFlowStyle
void setFlowStyle(bool isFlowStyle=true)
Definition: ValueTree.h:271
cnoid::Mapping::size
int size() const
Definition: ValueTree.h:268
cnoid::Mapping::openFlowStyleListing
Listing * openFlowStyleListing(const std::string &key)
Definition: ValueTree.h:327
cnoid::Mapping::operator[]
ValueNode & operator[](const std::string &key) const
Definition: ValueTree.h:299
cnoid::Listing::append
void append(const std::string &value, int maxColumns, int numValues=0, StringStyle stringStyle=PLAIN_STRING)
Definition: ValueTree.h:587
cnoid::ValueNode::isDegreeMode
bool isDegreeMode() const
Definition: ValueTree.h:85
cnoid::write
Listing * write(Mapping *mapping, const std::string &key, const Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:145
cnoid::ValueNode::Exception::setPosition
void setPosition(int line, int column)
Definition: ValueTree.h:127
cnoid::ValueNode::isCollection
bool isCollection() const
Definition: ValueTree.h:69
cnoid::Mapping::keyStringStyle
StringStyle keyStringStyle() const
Definition: ValueTree.h:438
cnoid::ValueNode::toString
const std::string & toString() const
Definition: ValueTree.h:242
cnoid::DOUBLE_QUOTED
@ DOUBLE_QUOTED
Definition: ValueTree.h:24
cnoid::ValueNode::hasLineInfo
bool hasLineInfo() const
Definition: ValueTree.h:111
cnoid::FOLDED_STRING
@ FOLDED_STRING
Definition: ValueTree.h:24
cnoid::Mapping::begin
const_iterator begin() const
Definition: ValueTree.h:433
cnoid::ValueNode::isForcedRadianMode
bool isForcedRadianMode() const
Definition: ValueTree.h:82
cnoid::ValueNode::KeyNotFoundException::key
const std::string & key()
Definition: ValueTree.h:142
cnoid::ScalarNode::stringStyle
StringStyle stringStyle() const
Definition: ValueTree.h:225
cnoid::Listing::end
iterator end()
Definition: ValueTree.h:595
cnoid::ValueNode::LFType
TypeBit LFType() const
Definition: ValueTree.h:57
cnoid::ValueNode
Definition: ValueTree.h:34
cnoid::Mapping::read
bool read(std::initializer_list< const char * > keys, T &out_value) const
Definition: ValueTree.h:348
cnoid::Mapping::empty
bool empty() const
Definition: ValueTree.h:267
cnoid::ValueNode::indexInMapping
int indexInMapping() const
Definition: ValueTree.h:176
cnoid::ValueNode::TypeBit
TypeBit
Definition: ValueTree.h:44
cnoid::Mapping::createMapping
Mapping * createMapping(const std::string &key)
Definition: ValueTree.h:315
cnoid::ValueNode::typeBits
int typeBits
Definition: ValueTree.h:190
cnoid::Mapping::get
T get(const std::string &key, const T &defaultValue) const
Definition: ValueTree.h:373
cnoid::Listing::front
ValueNode * front() const
Definition: ValueTree.h:515
cnoid::Mapping::setDoubleFormat
void setDoubleFormat(const char *format)
Definition: ValueTree.h:278
cnoid::Mapping::doubleFormat
const char * doubleFormat()
Definition: ValueTree.h:280
cnoid::ValueNode::throwNotScalrException
void throwNotScalrException() const
Definition: ValueTree.cpp:414
cnoid::Listing::empty
bool empty() const
Definition: ValueTree.h:499
cnoid::Listing::end
const_iterator end() const
Definition: ValueTree.h:597
cnoid::ValueNode::toFloat
float toFloat() const
Definition: ValueTree.cpp:240
cnoid::ValueNode::EmptyKeyException
Definition: ValueTree.h:148
cnoid::Listing::back
ValueNode * back() const
Definition: ValueTree.h:519
cnoid::MAPPING
@ MAPPING
Definition: YAMLWriter.cpp:18
cnoid::read
bool read(const Mapping *mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:43
cnoid::ValueNode::isListing
bool isListing() const
Definition: ValueTree.h:95
cnoid::ValueNode::SyntaxException
Definition: ValueTree.h:163
cnoid::Listing::begin
const_iterator begin() const
Definition: ValueTree.h:596
cnoid::ValueNode::NotMappingException
Definition: ValueTree.h:157
cnoid::Mapping::createFlowStyleListing
Listing * createFlowStyleListing(const std::string &key)
Definition: ValueTree.h:335
cnoid::Listing::floatingNumberFormat
const char * floatingNumberFormat()
Definition: ValueTree.h:508
cnoid::Mapping::get
T get(std::initializer_list< const char * > keys, const T &defaultValue) const
Definition: ValueTree.h:392
cnoid::ref_ptr< ValueNode >
cnoid::ValueNode::toInt
int toInt() const
Definition: ValueTree.cpp:166
cnoid::SINGLE_QUOTED
@ SINGLE_QUOTED
Definition: ValueTree.h:24
cnoid::Listing::const_iterator
Container::const_iterator const_iterator
Definition: ValueTree.h:497
cnoid::Mapping::const_iterator
Container::const_iterator const_iterator
Definition: ValueTree.h:258
cnoid::ValueNode::line
int line() const
Definition: ValueTree.h:112
cnoid::ValueNode::Exception
Definition: ValueTree.h:120
cnoid::Mapping::get
std::string get(const std::string &key, const char *defaultValue) const
Definition: ValueTree.h:382
cnoid::ValueNodePtr
ref_ptr< ValueNode > ValueNodePtr
Definition: ValueTree.h:213
cnoid::ValueNode::nodeType
TypeBit nodeType() const
Definition: ValueTree.h:58
cnoid::Mapping::createFlowStyleMapping
Mapping * createFlowStyleMapping(const std::string &key)
Definition: ValueTree.h:319
cnoid::Listing::size
int size() const
Definition: ValueTree.h:500
cnoid::Listing::doubleFormat
const char * doubleFormat()
Definition: ValueTree.h:513
cnoid::Listing
Definition: ValueTree.h:484
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::LITERAL_STRING
@ LITERAL_STRING
Definition: ValueTree.h:24
cnoid::Mapping::openMapping
Mapping * openMapping(const std::string &key)
Definition: ValueTree.h:307
cnoid::StringStyle
StringStyle
Definition: ValueTree.h:24
cnoid::ValueNode::DocumentNotFoundException
Definition: ValueTree.h:166
cnoid::ValueNode::isString
bool isString() const
Definition: ValueTree.h:68
cnoid::ValueNode::NotListingException
Definition: ValueTree.h:160
cnoid::Mapping::end
const_iterator end() const
Definition: ValueTree.h:434
cnoid::PLAIN_STRING
@ PLAIN_STRING
Definition: ValueTree.h:24
cnoid::Mapping::createListing
Listing * createListing(const std::string &key)
Definition: ValueTree.h:331
cnoid::Mapping::read
T read(const std::string &key) const
Definition: ValueTree.h:441
cnoid::ValueNode::ValueNode
ValueNode()
Definition: ValueTree.h:181
cnoid::ValueNode::toDouble
double toDouble() const
Definition: ValueTree.cpp:217
cnoid::Listing::append
void append(int value, int maxColumns, int numValues=0)
Definition: ValueTree.h:562
cnoid::Listing::append
void append(ValueNode *node)
Definition: ValueTree.h:549
cnoid::ValueNode::isMapping
bool isMapping() const
Definition: ValueTree.h:91
cnoid::Listing::begin
iterator begin()
Definition: ValueTree.h:594
cnoid::ValueNode::setForcedRadianMode
void setForcedRadianMode(bool on=true)
Definition: ValueTree.h:83
cnoid::Referenced
Definition: Referenced.h:54
cnoid::Mapping::AssignMode
AssignMode
Definition: ValueTree.h:413
cnoid::ValueNode::KeyNotFoundException::setKey
void setKey(const std::string &key)
Definition: ValueTree.h:143
cnoid::Mapping::setAssignMode
void setAssignMode(AssignMode mode)
Definition: ValueTree.h:415
cnoid::ValueNode::FileException
Definition: ValueTree.h:169
cnoid::ScalarNode::stringValue
const std::string & stringValue() const
Definition: ValueTree.h:224
cnoid::Mapping::floatingNumberFormat
const char * floatingNumberFormat()
Definition: ValueTree.h:275
cnoid::ValueNode::UnknownNodeTypeException
Definition: ValueTree.h:172
cnoid::Listing::setFlowStyle
void setFlowStyle(bool isFlowStyle=true)
Definition: ValueTree.h:504
cnoid::ValueNode::column
int column() const
Definition: ValueTree.h:113
cnoid::Mapping::openFlowStyleMapping
Mapping * openFlowStyleMapping(const std::string &key)
Definition: ValueTree.h:311
cnoid::ScalarNode
Definition: ValueTree.h:216
cnoid::ValueNode::ScalarTypeMismatchException
Definition: ValueTree.h:154
cnoid::Listing::iterator
Container::iterator iterator
Definition: ValueTree.h:496
cnoid::Mapping::end
iterator end()
Definition: ValueTree.h:432
cnoid::ValueNode::Exception::line
int line() const
Definition: ValueTree.h:124
cnoid::ValueNode::NotScalarException
Definition: ValueTree.h:151
cnoid::Listing::setDoubleFormat
void setDoubleFormat(const char *format)
Definition: ValueTree.h:511
cnoid::ValueNode::setDegreeMode
void setDegreeMode()
Definition: ValueTree.h:87
cnoid::Listing::at
ValueNode * at(int i) const
Definition: ValueTree.h:523
cnoid::Listing::operator[]
ValueNode & operator[](int i) const
Definition: ValueTree.h:540
cnoid::ValueNode::KeyNotFoundException
Definition: ValueTree.h:140
cnoid::Mapping::iterator
Container::iterator iterator
Definition: ValueTree.h:257
cnoid::ListingPtr
ref_ptr< Listing > ListingPtr
Definition: ValueTree.h:629
cnoid::ValueNode::Exception::setMessage
void setMessage(const std::string &m)
Definition: ValueTree.h:131
cnoid::MappingPtr
ref_ptr< Mapping > MappingPtr
Definition: StdSceneWriter.h:12
cnoid::ValueNode::setAsHeaderInMapping
void setAsHeaderInMapping(int priority=1)
Definition: ValueTree.h:177
cnoid::Listing::append
void append(double value, int maxColumns, int numValues=0)
Definition: ValueTree.h:575
cnoid::Mapping::assign
void assign(const std::string &key, T &io_value, const T &defaultValue)
Definition: ValueTree.h:418
cnoid::Mapping::isFlowStyle
bool isFlowStyle() const
Definition: ValueTree.h:272
cnoid::Mapping::write
void write(const std::string &key, const char *value, StringStyle stringStyle=PLAIN_STRING)
Definition: ValueTree.h:402
cnoid::Listing::get
ValueNode & get(int i) const
Definition: ValueTree.h:530
cnoid::Mapping::writeAsListing
void writeAsListing(const std::string &key, const ArrayType &container)
Definition: ValueTree.h:620