• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ tinyxml2::XMLDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中tinyxml2::XMLDocument的典型用法代码示例。如果您正苦于以下问题:C++ XMLDocument类的具体用法?C++ XMLDocument怎么用?C++ XMLDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了XMLDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: from_XML

void NeuralParametersNorm::from_XML(const tinyxml2::XMLDocument& document)
{
    const tinyxml2::XMLElement* root_element = document.FirstChildElement("NeuralParametersNorm");

    if(!root_element)
    {
        std::ostringstream buffer;

        buffer << "OpenNN Exception: NeuralParametersNorm class.\n"
               << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
               << "Neural parameters norm element is NULL.\n";

        throw std::logic_error(buffer.str());
    }

  // Neural parameters norm weight
  {
     const tinyxml2::XMLElement* element = root_element->FirstChildElement("NeuralParametersNormWeight");

     if(element)
     {
        try
        {
           const double new_neural_parameters_norm_weight = atof(element->GetText());

           set_neural_parameters_norm_weight(new_neural_parameters_norm_weight);
        }
        catch(const std::logic_error& e)
        {
           std::cout << e.what() << std::endl;
        }
     }
  }

  // Display
  {
     const tinyxml2::XMLElement* element = root_element->FirstChildElement("Display");

     if(element)
     {
        try
        {
           const std::string new_display_string = element->GetText();

           set_display(new_display_string != "0");
        }
        catch(const std::logic_error& e)
        {
           std::cout << e.what() << std::endl;
        }
     }
  }
}
开发者ID:Quanteek,项目名称:OpenNN-CMake,代码行数:53,代码来源:neural_parameters_norm.cpp


示例2: throwIfError

/** Unfortunately, TinyXML2 does not provide good ways of reporting XML parsing
 * errors.  We could try to use GetErrorStr1() and GetErrorStr2(), but those
 * just return pointers to parts of the document, and it is not OK to print
 * parts of the document without carefully escaping special characters in it,
 * which is probably not worthwhile. */
static void throwIfError(const tinyxml2::XMLDocument & doc)
{
    if(!doc.Error()) { return; }

    std::string msg("XML error.");

    // doc.ErrorName is not available in Ubuntu's libtinyxml2-dev/trusty-backports package
    // (2.1.0).  But it would be nice to use it eventually once everyone has upgraded:
    // std::string msg("XML error: ");
    // msg += doc.ErrorName();
    // msg += ".";
    throw std::runtime_error(msg);
}
开发者ID:bhunting,项目名称:p-load,代码行数:18,代码来源:firmware_archive.cpp


示例3: string

	// прочитать группу Тегов c Загруженного файла XML
	// "локация тегов" - вектор "вглубь" структуры
	vector<string> rd_Xml_tags_Txt_reader::get_Tags_Txt__From_Xml_Doc(
		tinyxml2::XMLDocument& doc, const vector<const char*>& location, const char* tag)
	{
		vector<string> vTxt;
		unsigned loc_Sze = location.size();

		tinyxml2::XMLElement* ptEl_location;
		tinyxml2::XMLElement* ptEl;
		tinyxml2::XMLElement* ptEl_last;

		if(loc_Sze)
		{
			ptEl_location = doc.FirstChildElement(location[0]);
			for(unsigned n = 1; n < loc_Sze; n++)
			{
				ptEl_location = ptEl_location->FirstChildElement(location[n]);
			}
			ptEl = ptEl_location->FirstChildElement(tag);
			ptEl_last = ptEl_location->LastChildElement(tag);
		}
		else
		{
			ptEl = doc.FirstChildElement(tag);
			ptEl_last = doc.LastChildElement(tag);
		}

		const char* data;
		for(; ptEl; ptEl = ptEl->NextSiblingElement())
		{
			data = ptEl->GetText();
			if(data) vTxt.push_back( data );
			else vTxt.push_back( string() );
			if(ptEl == ptEl_last) break;
		}

		vTxt.shrink_to_fit();
		return vTxt;
	}
开发者ID:Redee,项目名称:RdEngine,代码行数:40,代码来源:rd_Xml_tags_Txt_reader.cpp


示例4: LoadFile

static tinyxml2::XMLError LoadFile(tinyxml2::XMLDocument &doc, const std::string &path)
{
    FILE *f = fopen(path.c_str(),"rb");
    if (!f)
        return tinyxml2::XML_ERROR_FILE_NOT_FOUND;

    // is file ok? if "path" is a folder then reading from it will cause ferror() to return a non-zero value
    fgetc(f);
    int errorcode = ferror(f);
    fclose(f);

    // if file is ok, try to load it
    return (errorcode == 0) ? doc.LoadFile(path.c_str()) : tinyxml2::XML_ERROR_FILE_NOT_FOUND;
}
开发者ID:AndrianDTR,项目名称:codelite,代码行数:14,代码来源:library.cpp


示例5: LoadXMLFromFile

// Загрузка данных в XML документ.
XMLError MainWindow::LoadXMLFromFile(QString& a_StrPath, tinyxml2::XMLDocument& a_xmlDoc)
{
    DialogFileError we;
    XMLError eErrOut;
    //
    eErrOut = XMLCheckResult(a_xmlDoc.LoadFile(a_StrPath.toStdString().c_str()));
    if(eErrOut)
    {
        LOG(LOG_CAT_W, "File error: " << a_StrPath.toStdString());
        we.exec();
    }
    else
    {
        LOG(LOG_CAT_I, "File loaded: " << a_StrPath.toStdString());
    }
    return eErrOut;
}
开发者ID:Intueor,项目名称:SEWorldDoctor,代码行数:18,代码来源:mainwindow.cpp


示例6: openXMLFile

static void openXMLFile(tinyxml2::XMLDocument & doc, const char* const filename)
{
	int const result = doc.LoadFile(filename);
	switch(result)
	{
		case tinyxml2::XML_SUCCESS:
			break;
		case tinyxml2::XML_ERROR_FILE_NOT_FOUND:
			throw std::runtime_error("File not found");
		case tinyxml2::XML_ERROR_FILE_COULD_NOT_BE_OPENED:
			throw std::runtime_error("File not found");
		default:
		{
			std::ostringstream oss;
			oss << "Parse error = " << result;
			throw std::runtime_error(oss.str());
		}
	};
}
开发者ID:bingjeff,项目名称:dart,代码行数:19,代码来源:ParserVsk.cpp


示例7: addTextureStageState

void addTextureStageState(tinyxml2::XMLDocument& doc, tinyxml2::XMLElement* ele, u32 stage, D3DTEXTURESTAGESTATETYPE tp, u32 vl)
{
	DWORD va = 0;
	if (tp == D3DTSS_COLOROP)
	{
		if (stage == 0)
		{
			va = D3DTOP_MODULATE;
		} 
		else
		{
			va = D3DTOP_DISABLE;
		}
	}
	else if (tp == D3DTSS_ALPHAOP)
	{
		if (stage == 0)
		{
			va = D3DTOP_SELECTARG1;
		} 
		else
		{
			va = D3DTOP_DISABLE;
		}
	}
	else if(tp == D3DTSS_TEXCOORDINDEX)
	{
		va = stage;
	}
	else
	{
		va = Material::tTextureStageStateDefault_[tp];
	}
	if(va != vl)
	{
		tinyxml2::XMLElement* a = doc.NewElement("TextureStageState");
		a->SetAttribute("stage", stage);
		a->SetAttribute("type", tp);
		a->SetAttribute("value", vl);
		ele->LinkEndChild(a);
	}
}
开发者ID:cpzhang,项目名称:zen,代码行数:42,代码来源:Mz.cpp


示例8: load

void TileMap::load(tinyxml2::XMLDocument & doc)
{
	std::string data;
	tinyxml2::XMLElement * element = doc.FirstChildElement("map");
	element->FirstChildElement("width")->QueryIntText(&m_width);
	element->FirstChildElement("height")->QueryIntText(&m_height);
	element->FirstChildElement("tile_size")->QueryIntText(&m_tileSize);
	data = element->FirstChildElement("data")->GetText();
	std::cout << "width: " << m_width << " height: " << m_height << "\n";


	std::istringstream ss(data);
	std::string token;
	while (std::getline(ss, token, ','))
	{
		if (m_tiles.size() == 0 || m_tiles.back().size() >= static_cast<unsigned>(m_width))
			m_tiles.emplace_back();
		m_tiles.back().push_back(std::stoi(token));
	}
}
开发者ID:kiwon0905,项目名称:Residents-vs-Aliens,代码行数:20,代码来源:TileMap.cpp


示例9: from_XML

void RegularizationTerm::from_XML(const tinyxml2::XMLDocument& document)
{
    // Display warnings

    const tinyxml2::XMLElement* display_element = document.FirstChildElement("Display");

    if(display_element)
    {
        std::string new_display_string = display_element->GetText();

        try
        {
            set_display(new_display_string != "0");
        }
        catch(const std::logic_error& e)
        {
            std::cout << e.what() << std::endl;
        }
    }
}
开发者ID:Artelnics,项目名称:OpenNN,代码行数:20,代码来源:regularization_term.cpp


示例10: Serialization

void Sphere::Serialization( tinyxml2::XMLDocument& xmlDoc , tinyxml2::XMLElement* pRootElement )
{
	{
		pRootElement->SetAttribute( "type" , GetName() );
	}

	{
		pRootElement->SetAttribute( "radius" , m_Radius );
	}

	{
		char* pText = new char[50];
		sprintf( pText , "%f,%f,%f" , mWorldPos.x , mWorldPos.y , mWorldPos.z );

		tinyxml2::XMLElement* pTransformElement = xmlDoc.NewElement( "transform" );

		pTransformElement->SetAttribute( "position" , pText );

		pRootElement->InsertEndChild( pTransformElement );

		SAFE_DELETE( pText );
	}
}
开发者ID:lonelyWaiting,项目名称:OpenLight,代码行数:23,代码来源:Sphere.cpp


示例11: openXMLFile

void openXMLFile(
  tinyxml2::XMLDocument& doc, const char* const filename,
  const common::ResourceRetrieverPtr& _retriever)
{
    common::ResourceRetrieverPtr retriever;
    if(_retriever)
      retriever = _retriever;
    else
      retriever = std::make_shared<common::LocalResourceRetriever>();

    const common::ResourcePtr resource = retriever->retrieve(filename);
    if(!resource)
    {
      dtwarn << "[openXMLFile] Failed opening URI '"
             << filename << "'.\n";
      throw std::runtime_error("Failed opening URI.");
    }

    // C++11 guarantees that std::string has contiguous storage.
    const size_t size = resource->getSize();
    std::string content;
    content.resize(size);
    if(resource->read(&content.front(), size, 1) != 1)
    {
      dtwarn << "[openXMLFile] Failed reading from URI '"
             << filename << "'.\n";
      throw std::runtime_error("Failed reading from URI.");
    }

    int const result = doc.Parse(&content.front());
    if(result != tinyxml2::XML_SUCCESS)
    {
      dtwarn << "[openXMLFile] Failed parsing XML: TinyXML2 returned error"
                " code " << result << ".\n";
      throw std::runtime_error("Failed parsing XML.");
    }
}
开发者ID:dtbinh,项目名称:dart,代码行数:37,代码来源:Parser.cpp


示例12: from_XML

void KappaCoefficientOptimizationThreshold::from_XML(const tinyxml2::XMLDocument& document)
{
    const tinyxml2::XMLElement* root_element = document.FirstChildElement("KappaCoefficientOptimizationThreshold");

    if(!root_element)
    {
        std::ostringstream buffer;

        buffer << "OpenNN Exception: KappaCoefficientOptimizationThreshold class.\n"
               << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
               << "KappaCoefficientOptimizationThreshold element is NULL.\n";

        throw std::logic_error(buffer.str());
    }

    // Minimum threshold
    {
        const tinyxml2::XMLElement* element = root_element->FirstChildElement("MinimumThreshold");

        if(element)
        {
           const double new_minimum_threshold = atof(element->GetText());

           try
           {
              set_minimum_threshold(new_minimum_threshold);
           }
           catch(const std::logic_error& e)
           {
              std::cout << e.what() << std::endl;
           }
        }
    }

    // Maximum threshold
    {
        const tinyxml2::XMLElement* element = root_element->FirstChildElement("MaximumThreshold");

        if(element)
        {
           const double new_maximum_threshold = atof(element->GetText());

           try
           {
              set_maximum_threshold(new_maximum_threshold);
           }
           catch(const std::logic_error& e)
           {
              std::cout << e.what() << std::endl;
           }
        }
    }

    // Step
    {
        const tinyxml2::XMLElement* element = root_element->FirstChildElement("Step");

        if(element)
        {
           const double new_step = atof(element->GetText());

           try
           {
              set_step(new_step);
           }
           catch(const std::logic_error& e)
           {
              std::cout << e.what() << std::endl;
           }
        }
    }

    // Reserve function data
    {
        const tinyxml2::XMLElement* element = root_element->FirstChildElement("ReserveFunctionData");

        if(element)
        {
            const std::string new_reserve_function_data = element->GetText();

            try
            {
                set_reserve_function_data(new_reserve_function_data != "0");
            }
            catch(const std::logic_error& e)
            {
               std::cout << e.what() << std::endl;
            }
        }
    }

    // Display
//    {
//        const tinyxml2::XMLElement* element = root_element->FirstChildElement("Display");

//        if(element)
//        {
//           const std::string new_display = element->GetText();

//           try
//.........这里部分代码省略.........
开发者ID:PuchoDeepLearningLabs,项目名称:OpenNN,代码行数:101,代码来源:kappa_coefficient_optimization_threshold.cpp


示例13: from_XML

void ProbabilisticLayer::from_XML(const tinyxml2::XMLDocument& document)
{
    std::ostringstream buffer;

    const tinyxml2::XMLElement* probabilistic_layer_element = document.FirstChildElement("ProbabilisticLayer");

    if(!probabilistic_layer_element)
    {
        buffer << "OpenNN Exception: ProbabilisticLayer class.\n"
               << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
               << "Probabilistic layer element is NULL.\n";

        throw std::logic_error(buffer.str());
    }

  // Probabilistic neurons number
  {
     const tinyxml2::XMLElement* element = probabilistic_layer_element->FirstChildElement("ProbabilisticNeuronsNumber");

     if(element)
     {
        const char* text = element->GetText();

        if(text)
        {
           try
           {
              set_probabilistic_neurons_number(atoi(text));
           }
           catch(const std::logic_error& e)
           {
              std::cout << e.what() << std::endl;
           }
        }
     }
  }

  // Probabilistic method
  {
     const tinyxml2::XMLElement* element = probabilistic_layer_element->FirstChildElement("ProbabilisticMethod");

     if(element)
     {
        const char* text = element->GetText();

        if(text)
        {
           try
           {
              std::string new_probabilistic_method(text);

              set_probabilistic_method(new_probabilistic_method);
           }
           catch(const std::logic_error& e)
           {
              std::cout << e.what() << std::endl;
           }
        }
     }
  }

    // Decision threshold
    {
       const tinyxml2::XMLElement* element = probabilistic_layer_element->FirstChildElement("DecisionThreshold");

       if(element)
       {
          const char* text = element->GetText();

          if(text)
          {
             try
             {
                  set_decision_threshold(atof(text));
             }
             catch(const std::logic_error& e)
             {
                std::cout << e.what() << std::endl;
             }
          }
       }
    }

  // Display
  {
     const tinyxml2::XMLElement* display_element = probabilistic_layer_element->FirstChildElement("Display");

     if(display_element)
     {
        std::string new_display_string = display_element->GetText();

        try
        {
           set_display(new_display_string != "0");
        }
        catch(const std::logic_error& e)
        {
           std::cout << e.what() << std::endl;
        }
     }
//.........这里部分代码省略.........
开发者ID:Grace,项目名称:OpenNN,代码行数:101,代码来源:probabilistic_layer.cpp


示例14: from_XML

void BoundingLayer::from_XML(const tinyxml2::XMLDocument& document)
{
      // Control sentence 
//      {
//         const char* text = bounding_layer_element->GetText();     

//         const std::string string(text);

//         if(string != "BoundingLayer")
//         {
//            std::ostringstream buffer;

//            buffer << "OpenNN Exception: BoundingLayer class.\n" 
//                   << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
//                   << "Unkown root element: " << text << ".\n";

//   	        throw std::logic_error(buffer.str());
//         }
//      }

  // Lower bounds
  {
     const tinyxml2::XMLElement* lower_bounds_element = document.FirstChildElement("LowerBounds");

     if(lower_bounds_element)
     {
        const char* lower_bounds_text = lower_bounds_element->GetText();

        if(lower_bounds_text)
        {
           Vector<double> new_lower_bounds;
           new_lower_bounds.parse(lower_bounds_text);

           try
           {
              set_lower_bounds(new_lower_bounds);
           }
           catch(const std::logic_error& e)
           {
              std::cout << e.what() << std::endl;
           }
        }
     }
  }

  // Upper bounds
  {
     const tinyxml2::XMLElement* upper_bounds_element = document.FirstChildElement("UpperBounds");

     if(upper_bounds_element)
     {
        const char* upper_bounds_text = upper_bounds_element->GetText();

        if(upper_bounds_text)
        {
           Vector<double> new_upper_bounds;
           new_upper_bounds.parse(upper_bounds_text);

           try
           {
              set_upper_bounds(new_upper_bounds);
           }
           catch(const std::logic_error& e)
           {
              std::cout << e.what() << std::endl;
           }
        }
     }
  }

  // Display
  {
     const tinyxml2::XMLElement* display_element = document.FirstChildElement("Display");

     if(display_element)
     {
        std::string new_display_string = display_element->GetText();

        try
        {
           set_display(new_display_string != "0");
        }
        catch(const std::logic_error& e)
        {
           std::cout << e.what() << std::endl;
        }
     }
  }
}
开发者ID:Artelnics,项目名称:OpenNN,代码行数:89,代码来源:bounding_layer.cpp


示例15: load

bool Library::load(const tinyxml2::XMLDocument &doc)
{
    const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement();

    if (rootnode == NULL)
        return false;

    if (strcmp(rootnode->Name(),"def") != 0)
        return false;

    for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
        if (strcmp(node->Name(),"memory")==0 || strcmp(node->Name(),"resource")==0) {
            if (strcmp(node->Name(), "memory")==0)
                while (!ismemory(++allocid));
            else
                while (!isresource(++allocid));
            for (const tinyxml2::XMLElement *memorynode = node->FirstChildElement(); memorynode; memorynode = memorynode->NextSiblingElement()) {
                if (strcmp(memorynode->Name(),"alloc")==0) {
                    _alloc[memorynode->GetText()] = allocid;
                    const char *init = memorynode->Attribute("init");
                    if (init && strcmp(init,"false")==0) {
                        returnuninitdata.insert(memorynode->GetText());
                    }
                } else if (strcmp(memorynode->Name(),"dealloc")==0)
                    _dealloc[memorynode->GetText()] = allocid;
                else if (strcmp(memorynode->Name(),"use")==0)
                    use.insert(memorynode->GetText());
                else
                    return false;
            }
        }

        else if (strcmp(node->Name(),"function")==0) {
            const char *name = node->Attribute("name");
            if (name == NULL)
                return false;

            for (const tinyxml2::XMLElement *functionnode = node->FirstChildElement(); functionnode; functionnode = functionnode->NextSiblingElement()) {
                if (strcmp(functionnode->Name(),"noreturn")==0)
                    _noreturn[name] = (strcmp(functionnode->GetText(), "true") == 0);
                else if (strcmp(functionnode->Name(),"leak-ignore")==0)
                    leakignore.insert(name);
                else if (strcmp(functionnode->Name(), "arg") == 0 && functionnode->Attribute("nr") != NULL) {
                    const int nr = atoi(functionnode->Attribute("nr"));
                    bool notnull = false;
                    bool notuninit = false;
                    bool formatstr = false;
                    bool strz = false;
                    for (const tinyxml2::XMLElement *argnode = functionnode->FirstChildElement(); argnode; argnode = argnode->NextSiblingElement()) {
                        if (strcmp(argnode->Name(), "not-null") == 0)
                            notnull = true;
                        else if (strcmp(argnode->Name(), "not-uninit") == 0)
                            notuninit = true;
                        else if (strcmp(argnode->Name(), "formatstr") == 0)
                            formatstr = true;
                        else if (strcmp(argnode->Name(), "strz") == 0)
                            strz = true;
                        else
                            return false;
                    }
                    argumentChecks[name][nr].notnull = notnull;
                    argumentChecks[name][nr].notuninit = notuninit;
                    argumentChecks[name][nr].formatstr = formatstr;
                    argumentChecks[name][nr].strz = strz;
                } else if (strcmp(functionnode->Name(), "ignorefunction") == 0) {
                    _ignorefunction[name] = (strcmp(functionnode->GetText(), "true") == 0);
                } else
                    return false;
            }
        }

        else if (strcmp(node->Name(),"files")==0) {
            for (const tinyxml2::XMLElement *functionnode = node->FirstChildElement(); functionnode; functionnode = functionnode->NextSiblingElement()) {
                if (strcmp(functionnode->Name(), "file") == 0) {
                    _markupExtensions.insert(functionnode->Attribute("ext"));
                    const char * report = functionnode->Attribute("reporterrors");
                    if (report)
                        _reporterrors[functionnode->Attribute("ext")] = strcmp(report, "true")==0;
                } else
                    return false;
            }
        }

        else if (strcmp(node->Name(), "keywords") == 0) {
            for (const tinyxml2::XMLElement *functionnode = node->FirstChildElement(); functionnode; functionnode = functionnode->NextSiblingElement()) {
                if (strcmp(functionnode->Name(), "library") == 0) {
                    const char * const extension = functionnode->Attribute("extension");
                    for (const tinyxml2::XMLElement *librarynode = functionnode->FirstChildElement(); librarynode; librarynode = librarynode->NextSiblingElement()) {
                        if (strcmp(librarynode->Name(), "keyword") == 0) {
                            _keywords[extension].push_back(librarynode->Attribute("name"));
                        } else
                            return false;
                    }
                } else
                    return false;
            }
        }

        else if (strcmp(node->Name(), "exported") == 0) {
            for (const tinyxml2::XMLElement *functionnode = node->FirstChildElement(); functionnode; functionnode = functionnode->NextSiblingElement()) {
//.........这里部分代码省略.........
开发者ID:brokeh,项目名称:cppcheck,代码行数:101,代码来源:library.cpp


示例16: load

bool Library::load(const tinyxml2::XMLDocument &doc)
{
    const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement();

    if (rootnode == NULL)
        return false;

    if (strcmp(rootnode->Name(),"def") != 0)
        return false;

    for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
        if (strcmp(node->Name(),"memory")==0 || strcmp(node->Name(),"resource")==0) {
            if (strcmp(node->Name(), "memory")==0)
                while (!ismemory(++allocid));
            else
                while (!isresource(++allocid));
            for (const tinyxml2::XMLElement *memorynode = node->FirstChildElement(); memorynode; memorynode = memorynode->NextSiblingElement()) {
                if (strcmp(memorynode->Name(),"alloc")==0) {
                    _alloc[memorynode->GetText()] = allocid;
                    const char *init = memorynode->Attribute("init");
                    if (init && strcmp(init,"false")==0) {
                        returnuninitdata.insert(memorynode->GetText());
                    }
                } else if (strcmp(memorynode->Name(),"dealloc")==0)
                    _dealloc[memorynode->GetText()] = allocid;
                else if (strcmp(memorynode->Name(),"use")==0)
                    use.insert(memorynode->GetText());
                else
                    return false;
            }
        }

        else if (strcmp(node->Name(),"function")==0) {
            const char *name = node->Attribute("name");
            if (name == NULL)
                return false;

            for (const tinyxml2::XMLElement *functionnode = node->FirstChildElement(); functionnode; functionnode = functionnode->NextSiblingElement()) {
                if (strcmp(functionnode->Name(),"noreturn")==0)
                    _noreturn[name] = (strcmp(functionnode->GetText(), "true") == 0);
                else if (strcmp(functionnode->Name(),"leak-ignore")==0)
                    leakignore.insert(name);
                else if (strcmp(functionnode->Name(), "arg") == 0 && functionnode->Attribute("nr") != NULL) {
                    const int nr = atoi(functionnode->Attribute("nr"));
                    bool notbool = false;
                    bool notnull = false;
                    bool notuninit = false;
                    bool formatstr = false;
                    bool strz = false;
                    std::string valid;
                    for (const tinyxml2::XMLElement *argnode = functionnode->FirstChildElement(); argnode; argnode = argnode->NextSiblingElement()) {
                        if (strcmp(argnode->Name(), "not-bool") == 0)
                            notbool = true;
                        else if (strcmp(argnode->Name(), "not-null") == 0)
                            notnull = true;
                        else if (strcmp(argnode->Name(), "not-uninit") == 0)
                            notuninit = true;
                        else if (strcmp(argnode->Name(), "formatstr") == 0)
                            formatstr = true;
                        else if (strcmp(argnode->Name(), "strz") == 0)
                            strz = true;
                        else if (strcmp(argnode->Name(), "valid") == 0) {
                            // Validate the validation expression
                            const char *p = argnode->GetText();
                            if (!std::isdigit(*p))
                                return false;
                            for (; *p; p++) {
                                if (std::isdigit(*p))
                                    continue;
                                if (*p == '-' && std::isdigit(*(p-1)))
                                    continue;
                                if (*p == ',' && *(p+1) != ',')
                                    continue;
                                return false;
                            }

                            // Set validation expression
                            valid = argnode->GetText();
                        }

                        else
                            return false;
                    }
                    argumentChecks[name][nr].notbool   = notbool;
                    argumentChecks[name][nr].notnull   = notnull;
                    argumentChecks[name][nr].notuninit = notuninit;
                    argumentChecks[name][nr].formatstr = formatstr;
                    argumentChecks[name][nr].strz      = strz;
                    argumentChecks[name][nr].valid     = valid;
                } else if (strcmp(functionnode->Name(), "ignorefunction") == 0) {
                    _ignorefunction.insert(name);
                } else
                    return false;
            }
        }

        else if (strcmp(node->Name(), "markup") == 0) {
            const char * const extension = node->Attribute("ext");
            if (!extension)
                return false;
//.........这里部分代码省略.........
开发者ID:AndrianDTR,项目名称:codelite,代码行数:101,代码来源:library.cpp


示例17: from_XML

void Outputs::from_XML(const tinyxml2::XMLDocument& document)
{
    std::ostringstream buffer;

    const tinyxml2::XMLElement* outputs_element = document.FirstChildElement("Outputs");

    if(!outputs_element)
    {
        buffer << "OpenNN Exception: Outputs class.\n"
               << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
               << "Outputs element is NULL.\n";

        throw std::logic_error(buffer.str());
    }

    // Outputs number

   const tinyxml2::XMLElement* outputs_number_element = outputs_element->FirstChildElement("OutputsNumber");

   if(!outputs_number_element)
   {
       buffer << "OpenNN Exception: Outputs class.\n"
              << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
              << "Outputs number element is NULL.\n";

       throw std::logic_error(buffer.str());
   }

   const size_t outputs_number = atoi(outputs_number_element->GetText());

   set(outputs_number);

   unsigned index = 0; // size_t does not work

   const tinyxml2::XMLElement* start_element = outputs_number_element;

   for(size_t i = 0; i < outputs_number; i++)
   {
      const tinyxml2::XMLElement* item_element = start_element->NextSiblingElement("Item");
      start_element = item_element;

      if(!item_element)
      {
          buffer << "OpenNN Exception: Outputs class.\n"
                 << "void from_XML(const tinyxml2::XMLElement*) method.\n"
                 << "Item " << i+1 << " is NULL.\n";

          throw std::logic_error(buffer.str());
      }

     item_element->QueryUnsignedAttribute("Index", &index);

     if(index != i+1)
     {
         buffer << "OpenNN Exception: Outputs class.\n"
                << "void from_XML(const tinyxml2::XMLElement*) method.\n"
                << "Index " << index << " is not correct.\n";

         throw std::logic_error(buffer.str());
     }

     // Name

     const tinyxml2::XMLElement* name_element = item_element->FirstChildElement("Name");

     if(name_element)
     {
         if(name_element->GetText())
         {
            items[index-1].name = name_element->GetText();
         }
     }

     // Units

     const tinyxml2::XMLElement* units_element = item_element->FirstChildElement("Units");

     if(units_element)
     {
         if(units_element->GetText())
         {
            items[index-1].units = units_element->GetText();
         }
     }


     // Description

     const tinyxml2::XMLElement* description_element = item_element->FirstChildElement("Description");

     if(description_element)
     {
         if(description_element->GetText())
         {
            items[index-1].description = description_element->GetText();
         }
     }

   }
}
开发者ID:pappakrishnan,项目名称:OpenNN,代码行数:100,代码来源:outputs.cpp


示例18: from_XML

void PlugIn::from_XML(const tinyxml2::XMLDocument& document) {
  // Independent variables number
  {
    const tinyxml2::XMLElement* element =
        document.FirstChildElement("IndependentVariablesNumber");

    if (element) {
      const char* text = element->GetText();

      if (text) {
        try {
          set_independent_variables_number(atoi(text));
        }
        catch (const std::logic_error & e) {
          std::cout << e.what() << std::endl;
        }
      }
    }
  }

  // Dependent variables number
  {
    const tinyxml2::XMLElement* element =
        document.FirstChildElement("DependentVariablesNumber");

    if (element) {
      const char* text = element->GetText();

      if (text) {
        try {
          set_dependent_variables_number(atoi(text));
        }
        catch (const std::logic_error & e) {
          std::cout << e.what() << std::endl;
        }
      }
    }
  }

  // Input method
  {
    const tinyxml2::XMLElement* input_method_element =
        document.FirstChildElement("InputMethod");

    if (input_method_element) {
      const char* input_method_text = input_method_element->GetText();

      if (input_method_text) {
        try {
          set_input_method(input_method_text);
        }
        catch (const std::logic_error & e) {
          std::cout << e.what() << std::endl;
        }
      }
    }
  }

  // Template file_name
  {
    const tinyxml2::XMLElement* template_file_name_element =
        document.FirstChildElement("TemplateFileName");

    if (template_file_name_element) {
      const char* template_file_name_text =
          template_file_name_element->GetText();

      if (template_file_name_text) {
        try {
          set_template_file_name(template_file_name_text);
        }
        catch (const std::logic_error & e) {
          std::cout << e.what() << std::endl;
        }
      }
    }
  }

  // Input file_name
  {
    const tinyxml2::XMLElement* input_file_name_element =
        document.FirstChildElement("InputFileName");

    if (input_file_name_element) {
      const char* input_file_name_text = input_file_name_element->GetText();

      if (input_file_name_text) {
        try {
          set_input_file_name(input_file_name_text);
        }
        catch (const std::logic_error & e) {
          std::cout << e.what() << std::endl;
        }
      }
    }
  }

  // Batch file_name
  {
    const tinyxml2::XMLElement* script_file_name_element =
//.........这里部分代码省略.........
开发者ID:jrdodson,项目名称:opennn,代码行数:101,代码来源:plug_in.cpp


示例19: from_XML

void ScalingLayer::from_XML(const tinyxml2::XMLDocument& document)
{
    std::ostringstream buffer;

    const tinyxml2::XMLElement* scaling_layer_element = document.FirstChildElement("ScalingLayer");

    if(!scaling_layer_element)
    {
        buffer << "OpenNN Exception: ScalingLayer class.\n"
               << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
               << "Scaling layer element is NULL.\n";

        throw std::logic_error(buffer.str());
    }

    // Scaling neurons number

   const tinyxml2::XMLElement* scaling_neurons_number_element = scaling_layer_element->FirstChildElement("ScalingNeuronsNumber");

   if(!scaling_neurons_number_element)
   {
       buffer << "OpenNN Exception: ScalingLayer class.\n"
              << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
              << "Scaling neurons number element is NULL.\n";

       throw std::logic_error(buffer.str());
   }

   const size_t scaling_neurons_number = atoi(scaling_neurons_number_element->GetText());

   set(scaling_neurons_number);

   unsigned index = 0; // size_t does not work

   const tinyxml2::XMLElement* start_element = scaling_neurons_number_element;

   for(size_t i = 0; i < scaling_neurons_number; i++)
   {
       const tinyxml2::XMLElement* statistics_element = start_element->NextSiblingElement("Statistics");
       start_element = statistics_element;

       if(!statistics_element)
       {
           buffer << "OpenNN Exception: ScalingLayer class.\n"
                  << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
                  << "Statistics of scaling neuron " << i+1 << " is NULL.\n";

           throw std::logic_error(buffer.str());
       }

      statistics_element->QueryUnsignedAttribute("Index", &index);

      if(index != i+1)
      {
          buffer << "OpenNN Exception: ScalingLayer class.\n"
                 << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
                 << "Index " << index << " is not correct.\n";

          throw std::logic_error(buffer.str());
      }

      // Minimum

      const tinyxml2::XMLElement* minimum_element = statistics_element->FirstChildElement("Minimum");

      if(!minimum_element)
      {
         buffer << "OpenNN Exception: ScalingLayer class.\n"
                << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
                << "Minimum element " << i+1 << " is NULL.\n";

         throw std::logic_error(buffer.str());
      }

      if(minimum_element->GetText())
      {
          statistics[i].minimum = atof(minimum_element->GetText());
      }

      // Maximum

      const tinyxml2::XMLElement* maximum_element = statistics_element->FirstChildElement("Maximum");

      if(!maximum_element)
      {
         buffer << "OpenNN Exception: ScalingLayer class.\n"
                << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
                << "Maximum element " << i+1 << " is NULL.\n";

         throw std::logic_error(buffer.str());
      }

      if(maximum_element->GetText())
      {
          statistics[i].maximum = atof(maximum_element->GetText());
      }

      // Mean

    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ tinyxml2::XMLElement类代码示例发布时间:2022-05-31
下一篇:
C++ tinygettext::DictionaryManager类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap