HoverRace  2.0
ScalarNode.h
Go to the documentation of this file.
1 
2 // ScalarNode.h
3 //
4 // Copyright (c) 2008, 2009, 2015 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include <limits.h>
25 
26 #include "../OS.h"
27 
28 #include "Node.h"
29 
30 namespace HoverRace {
31 namespace Util {
32 namespace yaml {
33 
35 class ScalarNode : public Node
36 {
37  using SUPER = Node;
38 
39 public:
40  ScalarNode(yaml_document_t *doc, yaml_node_t *node);
41  virtual ~ScalarNode();
42 
43 public:
44  std::string AsString() const;
45  bool AsBool(bool def) const;
46  double AsDouble(double def, double min, double max) const;
47  float AsFloat(float def, float min, float max) const;
48  int AsInt(int def, int min = INT_MIN, int max = INT_MAX) const;
50 
51 private:
52  char *value;
53 };
54 
55 } // namespace yaml
56 } // namespace Util
57 } // namespace HoverRace
Base class for LibYAML document nodes.
Definition: Node.h:31
boost::filesystem::path path_t
Definition: OS.h:57
bool AsBool(bool def) const
Convert this scalar to a boolean value.
Definition: ScalarNode.cpp:74
int AsInt(int def, int min=INT_MIN, int max=INT_MAX) const
Convert this scalar to an integer value.
Definition: ScalarNode.cpp:137
double AsDouble(double def, double min, double max) const
Convert this scalar to a double floating-point value.
Definition: ScalarNode.cpp:101
float AsFloat(float def, float min, float max) const
Convert this scalar to a floating-point value.
Definition: ScalarNode.cpp:119
std::string AsString() const
Returns the string value.
Definition: ScalarNode.cpp:64
yaml_document_t * doc
Definition: Node.h:45
Wrapper for LibYAML scalar nodes.
Definition: ScalarNode.h:35
HoverRace::Util::OS::path_t AsPath() const
Convert this scalar to a path.
Definition: ScalarNode.cpp:152
Node()
Definition: Node.h:34
char * value
Definition: ScalarNode.h:52
yaml_node_t * node
Definition: Node.h:46
Definition: Announcement.h:24
ScalarNode(yaml_document_t *doc, yaml_node_t *node)
Constructor.
Definition: ScalarNode.cpp:49
virtual ~ScalarNode()
Destructor.
Definition: ScalarNode.cpp:56