本文整理汇总了C++中yaml::Node::GetMark方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::GetMark方法的具体用法?C++ Node::GetMark怎么用?C++ Node::GetMark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yaml::Node
的用法示例。
在下文中一共展示了Node::GetMark方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_drawable
Drawable parse_drawable(const YAML::Node& node) {
const char* err =
"Expected drawable object, of form \n"
" type: image -or- animation -or- directional -or- lua \n"
" file: <filename>\n"
"-or- frames: <drawable list or file pattern>\n"
" Note: file patterns are of the form filename(min-max).extension\n"
"-or- function: <lua function>";
if (node.Type() == YAML::NodeType::Scalar) {
return Drawable(new Image(parse_str(node)));
}
if (node.Type() != YAML::NodeType::Map) {
throw YAML::RepresentationException(node.GetMark(), err);
}
std::string type = parse_optional(node, "type", std::string());
if ((type.empty() && yaml_has_node(node, "file")) || type == "image") {
return Drawable(new Image(parse_image(node)));
} else if (type == "animation") {
return Drawable(new Animation(parse_animation(node)));
} else if (type == "directional") {
return Drawable(new DirectionalDrawable(parse_directional(node)));
} else if (type == "lua") {
return Drawable(new LuaDrawable(parse_luadrawable(node)));
} else {
throw YAML::RepresentationException(node.GetMark(), err);
}
}
示例2: load
void Property::load( const YAML::Node& yaml_node )
{
if( yaml_node.Type() == YAML::NodeType::Scalar )
{
loadValue( yaml_node );
}
else if( yaml_node.Type() == YAML::NodeType::Map )
{
loadChildren( yaml_node );
}
else
{
printf( "Property::load() TODO: error handling - unexpected YAML type (Sequence) at line %d, column %d.\n",
yaml_node.GetMark().line, yaml_node.GetMark().column );
}
}
示例3: parse_directional
DirectionalDrawable parse_directional(const YAML::Node& node) {
const YAML::Node* framenode = yaml_find_node(node, "frames");
if (!framenode) {
throw YAML::RepresentationException(node.GetMark(),
"Expected 'frames:' for directional drawable object (has 'type: directional').");
}
return DirectionalDrawable(parse_drawable_list(*framenode));
}
示例4: parse_animation
Animation parse_animation(const YAML::Node& node) {
const YAML::Node* framenode = yaml_find_node(node, "frames");
if (!framenode) {
throw YAML::RepresentationException(node.GetMark(),
"Expected 'frames:' for animation drawable object (has 'type: animation').");
}
return Animation(parse_drawable_list(*framenode));
}
示例5: parse_image
Image parse_image(const YAML::Node& node) {
const YAML::Node* filenode = yaml_find_node(node, "file");
if (!filenode) {
throw YAML::RepresentationException(node.GetMark(),
"Expected list (eg [\"file.png\"]), or pattern (eg \"file(0-9).png\").");
}
return Image(parse_str(*filenode));
}
示例6: parse_luadrawable
LuaDrawable parse_luadrawable(const YAML::Node& node) {
lua_State* L = ParseContext::luastate();
const YAML::Node* funcnode = yaml_find_node(node, "function");
if (!funcnode) {
throw YAML::RepresentationException(node.GetMark(),
"Expected 'function:' for lua drawable object (has 'type: lua').");
}
return LuaDrawable(L, parse_str(*funcnode));
}
示例7: ParseDerivedDimension
//==============================================================================
/// Parse a single derived dimension definition.
///
/// \param [in] dim The YAML map node for the dimension.
///
void DefinitionParser::ParseDerivedDimension( const YAML::Node& dim )
{
QString name;
dim["name"] >> name;
QString unit_name;
dim["unit"] >> unit_name;
QString derivation;
dim["derivation"] >> derivation;
DimensionId id = ParseDerivation( derivation );
(void)DefineDimension( dim.GetMark(), name, id, unit_name );
}
示例8: ParseBaseDimension
//==============================================================================
/// Parse a single base dimension definition.
///
/// \param [in] dim The YAML map node for the dimension.
///
void DefinitionParser::ParseBaseDimension( const YAML::Node& dim )
{
QString name;
dim["name"] >> name;
QString unit_name;
dim["unit"] >> unit_name;
DimensionId id;
id[unit_name] = 1;
(void)DefineDimension( dim.GetMark(), name, id, unit_name );
}
示例9: RepresentationException
// If node is a string, loads multiple images based on a pattern
// If node is a list, calls parse_drawable on individual entries
std::vector<Drawable> parse_drawable_list(const YAML::Node& node) {
std::vector<Drawable> drawables;
// Error if map
if (node.Type() == YAML::NodeType::Map) {
throw YAML::RepresentationException(node.GetMark(),
"Expected list (eg [\"file.png\"]), or pattern (eg \"file(0-9).png\").");
}
// Interpret as file pattern if string
if (node.Type() == YAML::NodeType::Scalar) {
std::vector<Image> images;
if (!filepattern_to_image_list(images, parse_str(node))) {
throw YAML::RepresentationException(node.GetMark(),
"Expected list (eg [\"file.png\"]), or pattern (eg \"file(0-9).png\").");
}
images_to_drawable_list(drawables, images);
return drawables;
}
// Accumulate from list
int size = node.size();
for (int i = 0; i < size; i++) {
const YAML::Node& child = node[i];
// Expand any file patterns, or image file names
if (child.Type() == YAML::NodeType::Scalar) {
std::vector<Image> images;
filepattern_to_image_list(images, parse_str(child));
images_to_drawable_list(drawables, images);
} else {
parse_drawable(child);
}
}
return drawables;
}
示例10: ParseConvertedUnit
//==============================================================================
/// Parse a single converted unit definition.
///
/// \param [in] unit The YAML map node for the unit.
///
void DefinitionParser::ParseConvertedUnit( const YAML::Node& unit )
{
QString name;
unit["name"] >> name;
QString base_unit_name;
const YAML::Node& dim_node( unit["dimension"] );
QString dim_name;
dim_node >> dim_name;
Dimension *dim_p = m_result->GetDimension( dim_name );
if ( !dim_p )
{
const YAML::Mark& mark( dim_node.GetMark() );
throw ParseError( m_file, mark.line,
UNDEFINED_DIM_NAME.arg( dim_name ).arg( mark.line ) );
}
Unit *unit_p = DefineUnit( unit.GetMark(), name, dim_p );
ParseConversions( unit["conversion"], unit_p );
}