-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from mudream4869/dev
Dev
- Loading branch information
Showing
10 changed files
with
89 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "third_party/googletest"] | ||
path = tests/third_party/googletest | ||
url = [email protected]:google/googletest.git | ||
[submodule "third_party/yaml-cpp"] | ||
path = third_party/yaml-cpp | ||
url = [email protected]:jbeder/yaml-cpp.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <mukyu/cablin/common/yamlutil.hpp> | ||
|
||
#include <mukyu/cablin/core/error.hpp> | ||
|
||
#include <mukyu/cablin/core/value.hpp> | ||
|
||
#include <yaml-cpp/yaml.h> | ||
|
||
#include <optional> | ||
#include <string> | ||
|
||
|
||
namespace mukyu { | ||
namespace cablin { | ||
namespace common { | ||
|
||
|
||
namespace mccore = mukyu::cablin::core; | ||
|
||
|
||
mccore::Value valueNodeToValue(mccore::ValueType type, | ||
const YAML::Node& valueNode) { | ||
if (valueNode == nullptr) { | ||
// return zero value of the type | ||
return mccore::Value(type); | ||
} | ||
|
||
switch (type) { | ||
case mccore::ValueType::BOOL: | ||
return valueNode.as<bool>(); | ||
case mccore::ValueType::FLOAT: | ||
return valueNode.as<float>(); | ||
case mccore::ValueType::INT: | ||
return valueNode.as<int>(); | ||
case mccore::ValueType::INT64: | ||
return valueNode.as<int64_t>(); | ||
case mccore::ValueType::STRING: | ||
return valueNode.as<std::string>(); | ||
case mccore::ValueType::NONE: | ||
return {}; | ||
} | ||
|
||
std::string msg = | ||
"valueNodeToValue: " + std::to_string(static_cast<int>(type)) + | ||
" is not an value type"; | ||
|
||
throw mccore::makeParsingException(msg, valueNode.Mark()); | ||
} | ||
|
||
|
||
} // namespace common | ||
} // namespace cablin | ||
} // namespace mukyu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule googletest
added at
703bd9