本文整理汇总了C++中CL_DomElement::get_first_child方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_DomElement::get_first_child方法的具体用法?C++ CL_DomElement::get_first_child怎么用?C++ CL_DomElement::get_first_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_DomElement
的用法示例。
在下文中一共展示了CL_DomElement::get_first_child方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_child_string_ns
void CL_DomElement::set_child_string_ns(const CL_DomString &namespace_uri, const CL_DomString &qualified_name, const CL_DomString &value)
{
CL_DomString local_name;
CL_DomString::size_type pos = qualified_name.find(L':');
if (pos != CL_DomString::npos)
local_name = qualified_name.substr(pos+1);
else
local_name = qualified_name;
CL_DomElement element = named_item_ns(namespace_uri, local_name).to_element();
if (element.is_null())
{
element = get_owner_document().create_element_ns(namespace_uri, qualified_name);
append_child(element);
}
CL_DomText dom_text = get_owner_document().create_text_node(value);
if (element.get_first_child().is_text())
{
CL_DomNode temp_domnode = element.get_first_child();
replace_child(dom_text, temp_domnode);
}
else
{
element.append_child(dom_text);
}
}
示例2: get_child_string_ns
CL_DomString CL_DomElement::get_child_string_ns(const CL_DomString &namespace_uri, const CL_DomString &local_name, const CL_DomString &default_value) const
{
CL_DomElement element = named_item_ns(namespace_uri, local_name).to_element();
if (!element.is_null() && element.get_first_child().is_text())
return element.get_first_child().to_text().get_node_value();
else
return default_value;
}
示例3: set_child_string
void CL_DomElement::set_child_string(const CL_DomString &name, const CL_DomString &value)
{
CL_DomElement element = named_item(name).to_element();
if (element.is_null())
{
element = get_owner_document().create_element(name);
append_child(element);
}
while (!element.get_first_child().is_null())
{
CL_DomNode my_child = element.get_first_child();
element.remove_child(my_child);
}
CL_DomText dom_text = get_owner_document().create_text_node(value);
element.append_child(dom_text);
}
示例4: load_texture
void CL_Collada_Effect_Texture_Impl::load_texture(CL_DomElement &profile_element, CL_DomElement &newparam_element, CL_DomElement &sampler2d_element, std::vector<CL_Collada_Image> &library_images)
{
sid = newparam_element.get_attribute("sid");
CL_DomElement source_element = sampler2d_element.named_item("source").to_element();
if (source_element.is_null())
throw CL_Exception("source is missing");
CL_String source_name = source_element.get_text();
// Find the corresponding surface
CL_DomElement surface_element;
CL_DomNode cur_child(profile_element.get_first_child());
while (!cur_child.is_null())
{
if(cur_child.get_node_name() == "newparam")
{
CL_DomElement newparam_element = cur_child.to_element();
CL_String new_sid = newparam_element.get_attribute("sid");
if (new_sid == source_name)
{
surface_element = newparam_element.named_item("surface").to_element();
if (!surface_element.is_null())
break; // Found match
}
}
cur_child = cur_child.get_next_sibling();
}
if (surface_element.is_null())
throw CL_Exception("Cannot find the corresponding surface");
CL_DomElement init_from_element = surface_element.named_item("init_from").to_element();
if (init_from_element.is_null())
throw CL_Exception("Only init_from surfaces are supported");
CL_String image_name = init_from_element.get_text();
unsigned int size = library_images.size();
for (unsigned int cnt=0; cnt < size; cnt++)
{
if (library_images[cnt].get_id() == image_name)
{
image = library_images[cnt];
break;
}
}
if (image.is_null())
throw CL_Exception("Cannot find requested image in the image library");
}
示例5: parse_sectiondef
void ReferenceFunction::parse_sectiondef(CL_DomElement sectiondef)
{
CL_DomNode cur_node;
for (cur_node = sectiondef.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
{
CL_DomElement cur_element = cur_node.to_element();
if (cur_element.is_null()) continue;
CL_String tag_name = cur_element.get_tag_name();
if (tag_name == "memberdef")
{
parse_memberdef(cur_element);
}
}
}
示例6: get_params_list
void ReferenceFunction::get_params_list(const CL_DomElement &element)
{
CL_DomNode cur_node;
for (cur_node = element.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
{
if (!cur_node.is_element()) continue;
CL_DomElement cur_element = cur_node.to_element();
if (cur_element.get_tag_name() == "parameterlist")
{
CL_String kind = cur_element.get_attribute("kind");
if (kind != "param") continue;
CL_String param_name, param_description;
CL_DomNode param_node;
for (param_node = cur_element.get_first_child(); !param_node.is_null(); param_node = param_node.get_next_sibling())
{
if (!param_node.is_element()) continue;
CL_DomElement param_element = param_node.to_element();
if (param_element.get_tag_name() == "parametername")
{
param_name = param_element.get_text();
}
else if (param_element.get_tag_name() == "parameterdescription")
{
param_description = ReferenceDocs::get_formatted(param_element);
}
}
if (!param_name.empty())
{
ReferenceFunctionParameter parameter;
parameter.name = param_name;
parameter.description = param_description;
parameters.push_back(parameter);
}
}
else
{
get_params_list(cur_element);
}
}
}
示例7: load_inputs
void CL_Collada_Triangles_Impl::load_inputs(CL_DomElement &polylist_element, std::vector<CL_Collada_Source> &sources, CL_Collada_Vertices &vertices)
{
stride = 1;
CL_DomNode cur_child(polylist_element.get_first_child());
while (!cur_child.is_null())
{
if(cur_child.get_node_name() == "input")
{
CL_DomElement input_element = cur_child.to_element();
CL_Collada_Input_Shared new_input(input_element, sources, vertices);
// Find the stride
int offset = new_input.get_offset();
offset++; // Make comparible with stride (1 to x)
if (offset > stride)
stride = offset;
inputs.push_back( new_input );
}
cur_child = cur_child.get_next_sibling();
}
}
示例8: load
void ReferenceFunction::load(CL_String member_name, CL_DomElement class_element)
{
if (class_element.get_tag_name() != "compounddef")
throw CL_Exception("Expected compounddef element");
name = member_name;
CL_DomNode cur_node;
for (cur_node = class_element.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
{
CL_DomElement cur_element = cur_node.to_element();
if (cur_element.is_null()) continue;
CL_String tag_name = cur_element.get_tag_name();
if ( (tag_name == "sectiondef") && (
(cur_element.get_attribute("kind") == "user-defined") ||
(cur_element.get_attribute("kind") == "public-func") ||
(cur_element.get_attribute("kind") == "public-static-func") ) )
{
parse_sectiondef(cur_element);
}
}
}
示例9: parse_memberdef
void ReferenceFunction::parse_memberdef(CL_DomElement memberdef)
{
CL_DomElement element_name = memberdef.named_item("name").to_element();
if (element_name.is_null() || element_name.get_text() != name)
return;
CL_String type, type_formatted, definition, argsstring;
std::vector<CL_String> cur_params;
CL_DomNode cur_node;
for (cur_node = memberdef.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
{
CL_DomElement cur_element = cur_node.to_element();
if (cur_element.is_null()) continue;
CL_String tag_name = cur_element.get_tag_name();
if (tag_name == "type")
{
type = cur_element.get_text();
type_formatted = ReferenceDocs::get_formatted(cur_element);
}
else if (tag_name == "definition")
{
definition = CL_StringHelp::trim(ReferenceDocs::escape_code(cur_element.get_text()));
}
else if (tag_name == "argsstring")
{
argsstring = cur_element.get_text();
}
else if (tag_name == "param")
{
CL_String param_type = ReferenceDocs::get_formatted(cur_element.named_item("type").to_element());
CL_String param_name = cur_element.named_item("declname").to_element().get_text();
CL_String param_defval = ReferenceDocs::get_formatted(cur_element.named_item("defval").to_element());
CL_String param_text = param_type + " " + param_name;
if (!param_defval.empty())
param_text += CL_String(" = ") + param_defval;
cur_params.push_back(param_text);
}
else if (tag_name == "briefdescription")
{
brief_description = ReferenceDocs::get_formatted(cur_element);
}
else if (tag_name == "detaileddescription")
{
detailed_description = ReferenceDocs::get_formatted(cur_element);
get_params_list(cur_element);
}
}
CL_String cur_declaration;
cur_declaration += cl_format("\t%1(", definition);
for (unsigned int index_params = 0; index_params < cur_params.size(); index_params++)
{
if (index_params > 0)
cur_declaration += ",";
cur_declaration += cl_format("\n\t\t%1", cur_params[index_params]);
}
cur_declaration += ");\n";
if (!declaration.empty())
declaration += "\n";
declaration += cur_declaration;
}
示例10: main
int ConsoleProgram::main(const std::vector<CL_String> &args)
{
// Setup clanCore:
CL_SetupCore setup_core;
// Initialize the ClanLib display component
CL_SetupDisplay setup_display;
// Create a console Window if one does not exist:
CL_ConsoleWindow console_window("Console", 80, 600);
try
{
//получение параметра запуска
for (std::vector<CL_String>::const_iterator iter_args = args.begin(); iter_args != args.end(); ++iter_args)
CL_Console::write_line( *iter_args );
//получение имени директории для сохранения
CL_String workDirectoryName;
if (args.size() > 1)
{
//полное имя рабочей директории
workDirectoryName = args[1];
//конвертирование из CP-1251 в UTF-8 имени рабочей директории
workDirectoryName = decode(workDirectoryName);
}
else
{
//получение полного пути к текущему каталогу
workDirectoryName = CL_Directory::get_current();
}
CL_Console::write_line("workDirectoryName: %1", workDirectoryName);
//получение имени последней директории
CL_String locationName = CL_PathHelp::remove_trailing_slash(workDirectoryName);
locationName = CL_PathHelp::get_filename(locationName);
CL_Console::write_line("locationName: %1", locationName);
CL_String tempDir = CL_PathHelp::add_trailing_slash(workDirectoryName) + "temp\\";
CL_DirectoryScanner directoryScanner;
directoryScanner.scan(tempDir, "*.export");
while (directoryScanner.next())
{
//имя обрабатываемого файла
CL_String fileName;
if (directoryScanner.is_directory())
continue;
//получение полного имени файла экспорта
fileName = directoryScanner.get_pathname();
//конвертирование из CP-1251 в UTF-8
fileName = decode(fileName);
CL_Console::write_line("find: %1", fileName);
//открытие XML файла
CL_File fileXML;
bool is_opened = fileXML.open(fileName);
if( !is_opened )
return PrintError( CL_String("Can't open file: ") + fileName );
//Создание объекта DOM парсера
CL_DomDocument document(fileXML);
//получение root узла
CL_DomElement root = document.get_document_element();
if( root.get_local_name() != "resources")
{
CL_Console::write_line("Root name can't be: %1", root.get_local_name().c_str());
return PrintError("");
}
//цикл по потомкам "resources"
for (CL_DomNode cur = root.get_first_child(); !cur.is_null(); cur = cur.get_next_sibling())
{
//загрузка только спрайтов
if (cur.get_node_name() != "sprite")
continue;
CL_DomElement element = cur.to_element();
//проверка на обязательные параметры
if (!element.has_attribute("name"))
return PrintError("Error: can't find parametr \"name\"");
CL_DomString name = element.get_attribute("name");
int x = element.get_attribute_int("x");
int y = element.get_attribute_int("y");
//добавление спрайта
sprites.push_back( S_Sprite(name, CL_Vec2i(x, y) ) );
//цикл по "image" (формирование списка имен файлов)
for (CL_DomNode cur_image = cur.get_first_child(); !cur_image.is_null(); cur_image = cur_image.get_next_sibling())
{
//загрузка только image
if (cur_image.get_node_name() != "image")
continue;
CL_DomElement element_image = cur_image.to_element();
CL_DomString file = element_image.get_attribute("file");
//конвертирование из CP-1251 в UTF-8 имени файла изображения
//.........这里部分代码省略.........
示例11: if
void CL_GUIXMLLoaderVersion_1_0::load(CL_DomElement &element, CL_GUIComponent *parent)
{
CL_DomElement e = element.get_first_child().to_element();
dialog_width = 0;
dialog_height = 0;
while (e.is_element())
{
CL_String tag = e.get_tag_name();
CL_GUIComponent *new_comp = 0;
if (tag == "button")
{
CL_PushButton *co = new CL_PushButton(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
new_comp = co;
}
else if (tag == "checkbox")
{
CL_CheckBox *co = new CL_CheckBox(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
new_comp = co;
}
else if (tag == "radiobutton")
{
CL_RadioButton *co = new CL_RadioButton(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
if (e.has_attribute("group"))
co->set_group_name(e.get_attribute("group"));
new_comp = co;
}
else if (tag == "label")
{
CL_Label *co = new CL_Label(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
new_comp = co;
}
else if (tag == "toolbar")
{
CL_ToolBar *co = new CL_ToolBar(parent);
new_comp = co;
}
else if (tag == "progressbar")
{
CL_ProgressBar *co = new CL_ProgressBar(parent);
new_comp = co;
}
else if (tag == "lineedit")
{
CL_LineEdit *co = new CL_LineEdit(parent);
if (e.has_attribute("text"))
co->set_text(e.get_attribute("text"));
new_comp = co;
}
else if (tag == "slider")
{
CL_Slider *co = new CL_Slider(parent);
co->set_min(CL_StringHelp::text_to_int(e.get_attribute("min")));
co->set_max(CL_StringHelp::text_to_int(e.get_attribute("max")));
co->set_tick_count(CL_StringHelp::text_to_int(e.get_attribute("ticks")));
co->set_page_step(CL_StringHelp::text_to_int(e.get_attribute("page_step")));
new_comp = co;
}
else if (tag == "listview")
{
CL_ListView *co = new CL_ListView(parent);
CL_ListViewHeader *header = co->get_header();
std::vector<CL_DomNode> columns_nodes = e.select_nodes("listview_header/listview_column");
for(size_t i = 0; i < columns_nodes.size(); ++i)
{
CL_DomElement column_element = columns_nodes[i].to_element();
CL_String id = column_element.get_attribute("col_id");
CL_String caption = column_element.get_attribute("caption");
int width = column_element.get_attribute_int("width");
CL_ListViewColumnHeader column = header->create_column(id, caption);
column.set_width(width);
header->append(column);
}
new_comp = co;
}
else if (tag == "tab")
{
CL_Tab *co = new CL_Tab(parent);
new_comp = co;
CL_DomElement tab_child = e.get_first_child().to_element();
while (tab_child.is_element())
{
if (tab_child.get_tag_name() == "tabpage")
{
CL_String label = tab_child.get_attribute("label", "Error: NO LABEL!");
int id = CL_StringHelp::text_to_int(tab_child.get_attribute("id", "0"));
//.........这里部分代码省略.........
示例12: load
void CL_ResourceManager::load(CL_IODevice file, CL_VirtualDirectory directory)
{
CL_DomDocument new_document;
new_document.load(file);
// Check if loaded document uses namespaces and if its a clanlib resources xml document:
CL_DomElement doc_element = new_document.get_document_element();
if (doc_element.get_namespace_uri().empty() && doc_element.get_local_name() == "resources")
{
impl->ns_resources = CL_String();
}
else if (doc_element.get_namespace_uri() == "http://clanlib.org/xmlns/resources-1.0")
{
if (doc_element.get_local_name() != "resources")
throw CL_Exception("ClanLib resource documents must begin with a resources element.");
impl->ns_resources = "http://clanlib.org/xmlns/resources-1.0";
}
else
{
throw CL_Exception("XML document is not a ClanLib resources document.");
}
impl->document = new_document;
impl->directory = directory;
impl->resources.clear();
std::vector<CL_String> section_stack;
std::vector<CL_DomNode> nodes_stack;
section_stack.push_back(CL_String());
nodes_stack.push_back(doc_element.get_first_child());
while (!nodes_stack.empty())
{
if (nodes_stack.back().is_element())
{
CL_DomElement element = nodes_stack.back().to_element();
if (element.get_namespace_uri() == impl->ns_resources && element.get_local_name() == "section")
{
CL_String section_name = element.get_attribute_ns(impl->ns_resources, "name");
section_stack.push_back(section_stack.back() + CL_PathHelp::add_trailing_slash(section_name, CL_PathHelp::path_type_virtual));
nodes_stack.push_back(element.get_first_child());
continue;
}
else if (element.has_attribute_ns(impl->ns_resources, "name"))
{
CL_String resource_name = element.get_attribute_ns(impl->ns_resources, "name");
CL_String resource_id = section_stack.back() + resource_name;
impl->resources[resource_id] = CL_Resource(element, *this);
}
}
nodes_stack.back() = nodes_stack.back().get_next_sibling();
while (nodes_stack.back().is_null())
{
nodes_stack.pop_back();
section_stack.pop_back();
if (nodes_stack.empty())
break;
nodes_stack.back() = nodes_stack.back().get_next_sibling();
}
}
}