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

C++ xml::DOMParser类代码示例

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

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



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

示例1: uri

Poco::AutoPtr<Poco::XML::Document> Twitter::invoke(const std::string& httpMethod, const std::string& twitterMethod, Poco::Net::HTMLForm& form)
{
    // Create the request URI.
    // We use the XML version of the Twitter API.
    Poco::URI uri(_uri + twitterMethod + ".xml");
    std::string path(uri.getPath());

    Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
    Poco::Net::HTTPRequest req(httpMethod, path, Poco::Net::HTTPMessage::HTTP_1_1);

    // Add username and password (HTTP basic authentication) to the request.
    Poco::Net::HTTPBasicCredentials cred(_username, _password);
    cred.authenticate(req);

    // Send the request.
    form.prepareSubmit(req);
    std::ostream& ostr = session.sendRequest(req);
    form.write(ostr);

    // Receive the response.
    Poco::Net::HTTPResponse res;
    std::istream& rs = session.receiveResponse(res);

    // Create a DOM document from the response.
    Poco::XML::DOMParser parser;
    parser.setFeature(Poco::XML::DOMParser::FEATURE_FILTER_WHITESPACE, true);
    parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false);
    Poco::XML::InputSource source(rs);
    Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&source);

    // If everything went fine, return the XML document.
    // Otherwise look for an error message in the XML document.
    if (res.getStatus() == Poco::Net::HTTPResponse::HTTP_OK)
    {
        return pDoc;
    }
    else
    {
        std::string error(res.getReason());
        Poco::AutoPtr<Poco::XML::NodeList> pList = pDoc->getElementsByTagName("error");
        if (pList->length() > 0)
        {
            error += ": ";
            error += pList->item(0)->innerText();
        }
        throw Poco::ApplicationException("Twitter Error", error);
    }
}
开发者ID:as2120,项目名称:ZPoco,代码行数:48,代码来源:Twitter.cpp


示例2: LoadInputMappings

    void Mapper::LoadInputMappings(const std::string &file)
    {
        if (boost::filesystem::exists(file) == false)
        {
            InputModuleOIS::LogInfo("Input mappings file not found, using default mappings.");

            Export(file);
        } else
        {
            InputModuleOIS::LogInfo("Loading input mappings from file " + file + "...");
            try
            {
                Poco::XML::InputSource source(file);
                Poco::XML::DOMParser parser;
                Poco::XML::AutoPtr<Poco::XML::Document> document = parser.parse(&source);
                
                if (!document.isNull())
                {
                    Poco::XML::Node* node = document->firstChild();
                    if (node)
                    {
                        LoadInputMappings(node);
                    }
                }
                else
                {
                    throw Exception("Failed to parse xml document.");
                }
            } catch (std::exception &e)
            {
                InputModuleOIS::LogInfo(e.what());
                InputModuleOIS::LogInfo("Failed to parse input mappings file, using default mappings.");
            }
        }
    }
开发者ID:Belsepubi,项目名称:naali,代码行数:35,代码来源:Mapper.cpp


示例3: in

XmlHandler::XmlHandler(std::string filename) {

  std::ifstream in(filename);
  Poco::XML::InputSource src(in);
  Poco::XML::DOMParser parser;
  pDoc = parser.parse(&src);
}
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:XmlHandler.cpp


示例4: isValid

/* Validate all of the pipelines in the given config file.
* This method does some basic parsing of the config file to learn
* about the various pipelines that exist in the file.
*/
bool ValidatePipeline::isValid(const char *a_configPath) const
{
    bool failed = false;

    std::ifstream in(a_configPath);
    if (!in) {
        fprintf(stdout, "Error opening pipeline config file: %s\n", a_configPath);
    } else {
        try {
            Poco::XML::InputSource src(in);
            Poco::XML::DOMParser parser;
            // basic parsing
            Poco::AutoPtr<Poco::XML::Document> xmlDoc = parser.parse(&src);

            // must have at least one pipeline element
            Poco::AutoPtr<Poco::XML::NodeList> pipelines =
                xmlDoc->getElementsByTagName(TskPipelineManager::PIPELINE_ELEMENT);

            if (pipelines->length() == 0) {
                fprintf(stdout, "No pipelines found in config file.\n");
            } else {
                // parse all pipelines in the config file
                for (unsigned long i = 0; i < pipelines->length(); i++)
                {
                    Poco::XML::Node * pNode = pipelines->item(i);
                    Poco::XML::Element* pElem = dynamic_cast<Poco::XML::Element*>(pNode);
                    Poco::XML::DOMWriter writer;
                    std::ostringstream pipelineXml;
                    writer.writeNode(pipelineXml, pNode);

                    std::string pipelineType = pElem->getAttribute(TskPipelineManager::PIPELINE_TYPE_ATTRIBUTE);

                    TskPipeline * pipeline = 0;
                    if (pipelineType == TskPipelineManager::FILE_ANALYSIS_PIPELINE_STR)
                        pipeline = new TskFileAnalysisPipeline();
                    else if (pipelineType == TskPipelineManager::REPORTING_PIPELINE_STR)
                        pipeline = new TskReportPipeline();
                    else {
                        fprintf(stdout, "Unsupported pipeline type: %s\n", pipelineType.c_str());
                        failed = true;
                        continue;
                    }

                    try {
                        pipeline->validate(pipelineXml.str());
                    } catch (...) {
                        fprintf(stdout, "Error parsing pipeline: %s\n", pElem->getAttribute(TskPipelineManager::PIPELINE_TYPE_ATTRIBUTE).c_str());
                        failed = true;
                    }
                    delete pipeline;
                }
            }
        } catch (Poco::XML::SAXParseException& ex) {
            fprintf(stderr, "Error parsing pipeline config file: %s (%s)\n", a_configPath, ex.what());
        }
    }

    // If any of the pipelines failed validation we return false
    return failed ? false : true;
}
开发者ID:pubbzz92,项目名称:OpenDF,代码行数:64,代码来源:tsk_validatepipeline.cpp


示例5: convert

    /**
    Execution method to run the extraction.
    @return implicit function if one could be found, or a NullImplicitFunction.
    */
    Mantid::Geometry::MDImplicitFunction* vtkDataSetToImplicitFunction::execute()
    {
      using Mantid::Geometry::NullImplicitFunction;
      using Mantid::Geometry::MDGeometryXMLDefinitions;
      std::unique_ptr<Mantid::Geometry::MDImplicitFunction> function =
          Mantid::Kernel::make_unique<NullImplicitFunction>();

      FieldDataToMetadata convert;
      std::string xmlString = convert(m_dataset->GetFieldData(), XMLDefinitions::metaDataId()); 
      if (false == xmlString.empty())
      {
        Poco::XML::DOMParser pParser;
        Poco::AutoPtr<Poco::XML::Document> pDoc = pParser.parseString(xmlString);
        Poco::XML::Element* pRootElem = pDoc->documentElement();
        Poco::XML::Element* functionElem = pRootElem->getChildElement(MDGeometryXMLDefinitions::functionElementName());
        if(NULL != functionElem)
        {
          auto existingFunction =
              std::unique_ptr<Mantid::Geometry::MDImplicitFunction>(
                  Mantid::API::ImplicitFunctionFactory::Instance()
                      .createUnwrapped(functionElem));
          function.swap(existingFunction);
        }
      }
      return function.release();
    }
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:30,代码来源:vtkDataSetToImplicitFunction.cpp


示例6: loadFromBuffer

//---------------------------------------------------------
bool ofXml::loadFromBuffer( const string& buffer )
{
    Poco::XML::DOMParser parser;
    
    // release and nullptr out if we already have a document
    if(document) {
        document->release();
    }
    
    try {
        document = parser.parseString(buffer);
    	element = (Poco::XML::Element*) document->firstChild();
    	document->normalize();
    	return true;
	} catch( const Poco::XML::SAXException & e ) {
		ofLogError("ofXml") << "parse error: " << e.message();
        document = new Poco::XML::Document;
        element = document->documentElement();
        return false;
    } catch( const exception & e ) {
        short msg = atoi(e.what());
        ofLogError("ofXml") << "parse error: " << DOMErrorMessage(msg);
        document = new Poco::XML::Document;
        element = document->documentElement();
        return false;
    }
}
开发者ID:8morikazuto,项目名称:openFrameworks,代码行数:28,代码来源:ofXml.cpp


示例7: fromXMLString

  /** Static method that sets the data inside this BoxController from an XML string
   *
   * @param xml :: string generated by BoxController::toXMLString()
   */
  void BoxController::fromXMLString(const std::string & xml)
  {
    using namespace Poco::XML;
    Poco::XML::DOMParser pParser;
    Poco::AutoPtr<Poco::XML::Document> pDoc = pParser.parseString(xml);
    Poco::XML::Element* pBoxElement = pDoc->documentElement();

    std::string s;
    s = pBoxElement->getChildElement("NumDims")->innerText();
    Strings::convert(s, nd);
    if (nd <= 0 || nd > 20) throw std::runtime_error("BoxController::fromXMLString(): Bad number of dimensions found.");

    size_t ival;
    Strings::convert(pBoxElement->getChildElement("MaxId")->innerText(), ival);
    this->setMaxId(ival);
    Strings::convert(pBoxElement->getChildElement("SplitThreshold")->innerText(), ival);
    this->setSplitThreshold(ival);
    Strings::convert(pBoxElement->getChildElement("MaxDepth")->innerText(), ival);
    this->setMaxDepth(ival);

    s = pBoxElement->getChildElement("SplitInto")->innerText();
    this->m_splitInto = splitStringIntoVector<size_t>(s);

    s = pBoxElement->getChildElement("NumMDBoxes")->innerText();
    this->m_numMDBoxes = splitStringIntoVector<size_t>(s);

    s = pBoxElement->getChildElement("NumMDGridBoxes")->innerText();
    this->m_numMDGridBoxes = splitStringIntoVector<size_t>(s);

    this->calcNumSplit();
  }
开发者ID:AlistairMills,项目名称:mantid,代码行数:35,代码来源:BoxController.cpp


示例8: parseRuninfo

/**
 * Parse the runinfo file to find the names of the neutron event files.
 *
 * @param runinfo Runinfo file with full path.
 * @param dataDir Directory where the runinfo file lives.
 * @param eventFilenames vector of all possible event files. This is filled by
 *the algorithm.
 */
void LoadPreNexus::parseRuninfo(const string &runinfo, string &dataDir,
                                vector<string> &eventFilenames) {
  eventFilenames.clear();

  // Create a Poco Path object for runinfo filename
  Poco::Path runinfoPath(runinfo, Poco::Path::PATH_GUESS);
  // Now lets get the directory
  Poco::Path dirPath(runinfoPath.parent());
  dataDir = dirPath.absolute().toString();
  g_log.debug() << "Data directory \"" << dataDir << "\"\n";

  std::ifstream in(runinfo.c_str());
  Poco::XML::InputSource src(in);

  Poco::XML::DOMParser parser;
  Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&src);

  Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ELEMENT);
  Poco::XML::Node *pNode = it.nextNode(); // root node
  while (pNode) {
    if (pNode->nodeName() == "RunInfo") // standard name for this type
    {
      pNode = pNode->firstChild();
      while (pNode) {
        if (pNode->nodeName() == "FileList") {
          pNode = pNode->firstChild();
          while (pNode) {
            if (pNode->nodeName() == "DataList") {
              pNode = pNode->firstChild();
              while (pNode) {
                if (pNode->nodeName() == "scattering") {
                  Poco::XML::Element *element =
                      static_cast<Poco::XML::Element *>(pNode);
                  eventFilenames.push_back(element->getAttribute("name"));
                }
                pNode = pNode->nextSibling();
              }
            } else // search for DataList
              pNode = pNode->nextSibling();
          }
        } else // search for FileList
          pNode = pNode->nextSibling();
      }
    } else // search for RunInfo
      pNode = pNode->nextSibling();
  }

  // report the results to the log
  if (eventFilenames.size() == 1) {
    g_log.debug() << "Found 1 event file: \"" << eventFilenames[0] << "\"\n";
  } else {
    g_log.debug() << "Found " << eventFilenames.size() << " event files:";
    for (auto &eventFilename : eventFilenames) {
      g_log.debug() << "\"" << eventFilename << "\" ";
    }
    g_log.debug() << "\n";
  }
}
开发者ID:DanNixon,项目名称:mantid,代码行数:66,代码来源:LoadPreNexus.cpp


示例9: load

void XMLConfiguration::load(Poco::XML::InputSource* pInputSource)
{
	poco_check_ptr (pInputSource);
	
	Poco::XML::DOMParser parser;
	parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false);
	parser.setFeature(Poco::XML::DOMParser::FEATURE_FILTER_WHITESPACE, true);
	Poco::XML::AutoPtr<Poco::XML::Document> pDoc = parser.parse(pInputSource);
	load(pDoc);
}
开发者ID:babafall,项目名称:Sogeti-MasterThesis-CrossPlatformMobileDevelopment,代码行数:10,代码来源:XMLConfiguration.cpp


示例10: loadChannelList

void Configure::loadChannelList(void)
{
    std::ifstream in(SystemInfo::instance().getExecutePath() + "\\config\\channelList.xml");
    Poco::XML::InputSource src(in);
    Poco::XML::DOMParser parser;

    try
    {
        Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&src);
        Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ALL);
        Poco::XML::Node* pNode = it.nextNode();

        static int index = 0;
		std::string channelInfo[3];
        while (pNode)  
        {
            if(pNode->nodeName() == "Row")
            {
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    continue; //No text node present
                }
                index = 0;
                if(m_encodeChannel == channelInfo[1])
                {
                    // 找到频道对照表
                    m_encodeChannelID = channelInfo[0];
                    m_encodeChannelPrefix = channelInfo[2];
                    LOG(INFO) << "get channel info : ID [" << m_encodeChannelID << "] Prefix[" << m_encodeChannelPrefix << "].";
                    return;
                }
            }
            if(pNode->nodeName() == "Cell")
            {
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    pNode = it.nextNode();
                    continue; //No text node present
                }
                channelInfo[index++] = pNode->nodeValue();
            }

            pNode = it.nextNode();//指向下一个node
        }
    }
    catch(std::exception& e)
    {
        LOG(ERROR) << "parse channelList xml file error." << e.what() ;
    }
}
开发者ID:zhiguangq,项目名称:hlsEncoder,代码行数:52,代码来源:Configure.cpp


示例11: ParseXML

const bool BoardListXML::ParseXML(const std::string &xml)
{
	bool parsed=false;
	Poco::XML::DOMParser dp;

	dp.setEntityResolver(0);

	Initialize();

	try
	{
		Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml));
		Poco::XML::Element *root=XMLGetFirstChild(doc,"BoardList");
		Poco::XML::Element *boardel=NULL;

		boardel=XMLGetFirstChild(root,"Board");
		while(boardel)
		{
			std::string name="";
			std::string description="";

			Poco::XML::Element *txt=XMLGetFirstChild(boardel,"Name");
			if(txt && txt->firstChild())
			{
				name=SanitizeSingleString(txt->firstChild()->getNodeValue());
				StringFunctions::LowerCase(name,name);
			}
			txt=XMLGetFirstChild(boardel,"Description");
			if(txt && txt->firstChild())
			{
				description=SanitizeSingleString(txt->firstChild()->getNodeValue());
			}

			if(name!="" && description!="")
			{
				m_boards.push_back(board(name,description));
			}

			boardel=XMLGetNextSibling(boardel,"Board");
		}

		parsed=true;

	}
	catch(...)
	{
	}

	return parsed;
}
开发者ID:SeekingFor,项目名称:FMS,代码行数:50,代码来源:boardlistxml.cpp


示例12: handleExtensions

void ExtensionPointService::handleExtensions(Bundle::ConstPtr pBundle, std::istream& istr, GenericHandler handler, Direction dir)
{
	Poco::XML::DOMParser parser;
	parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false);
	parser.setFeature(Poco::XML::DOMParser::FEATURE_FILTER_WHITESPACE, true);
	Poco::XML::InputSource source(istr);
	AutoPtr<Document> pDoc(parser.parse(&source));
	Node* pRoot = pDoc->firstChild();
	while (pRoot && pRoot->nodeName() != EXTENSIONS_ELEM)
	{
		pRoot = pRoot->nextSibling();
	}
	if (pRoot)
	{
		Node* pNode = (dir == DIR_FORWARD ? pRoot->firstChild() : pRoot->lastChild());
		while (pNode)
		{
			if (pNode->nodeType() == Node::ELEMENT_NODE)
			{
				if (pNode->nodeName() == EXTENSION_ELEM)
				{
					Element* pElem = static_cast<Element*>(pNode);
					const std::string& id = pElem->getAttribute(POINT_ATTR);
					if (!id.empty())
					{
						(this->*handler)(pBundle, id, pElem);
					}
					else
					{
						_logger.error(std::string("No point attribute found in extension element of bundle ")
							+ pBundle->symbolicName());
					}
				}
				else
				{
					_logger.warning(std::string("Unsupported element '")
						+ pNode->nodeName()
						+ "' found in "
						+ EXTENSIONS_XML
						+ " of bundle "
						+ pBundle->symbolicName());
				}
			}

			pNode = (dir == DIR_FORWARD ? pNode->nextSibling() : pNode->previousSibling());
		}
	}
	else throw Poco::NotFoundException("No extensions element found");
}
开发者ID:macchina-io,项目名称:macchina.io,代码行数:49,代码来源:ExtensionPointService.cpp


示例13: initializeXMLParser

/*
 * Initalize Poco XML Parser
 */
void LoadGroupXMLFile::initializeXMLParser(const std::string &filename) {
  const std::string xmlText = Kernel::Strings::loadFile(filename);

  // Set up the DOM parser and parse xml file
  Poco::XML::DOMParser pParser;
  try {
    m_pDoc = pParser.parseString(xmlText);
  } catch (Poco::Exception &exc) {
    throw Kernel::Exception::FileError(
        exc.displayText() + ". Unable to parse File:", filename);
  } catch (...) {
    throw Kernel::Exception::FileError("Unable to parse File:", filename);
  }
  // Get pointer to root element
  m_pRootElem = m_pDoc->documentElement();
  if (!m_pRootElem->hasChildNodes()) {
    throw Kernel::Exception::InstrumentDefinitionError(
        "No root element in XML instrument file", filename);
  }
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:23,代码来源:LoadDetectorsGroupingFile.cpp


示例14: ParseXML

const bool IdentityIntroductionXML::ParseXML(const std::string &xml)
{
	FreenetSSKKey ssk;
	bool parsed=false;
	Poco::XML::DOMParser dp;

	dp.setEntityResolver(0);

	Initialize();

	try
	{
		Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml));
		Poco::XML::Element *root=XMLGetFirstChild(doc,"IdentityIntroduction");
		Poco::XML::Element *txt=NULL;

		txt=XMLGetFirstChild(root,"Identity");
		if(txt)
		{
			if(txt->firstChild())
			{
				m_identity=SanitizeSingleString(txt->firstChild()->getNodeValue());
				if(ssk.TryParse(m_identity)==false)
				{
					return false;
				}
				m_identity=ssk.GetBaseKey();
			}
		}

		parsed=true;
	}
	catch(...)
	{
	}

	return parsed;
}
开发者ID:SeekingFor,项目名称:FMS,代码行数:38,代码来源:identityintroductionxml.cpp


示例15: initialize

void TskPipeline::initialize(const std::string & pipelineConfig)
{
    if (pipelineConfig.empty())
    {
        throw TskException("TskPipeline::initialize: Pipeline configuration string is empty.");
    }

    try
    {
        Poco::XML::DOMParser parser;
        Poco::AutoPtr<Poco::XML::Document> xmlDoc = parser.parseString(pipelineConfig);

        // Get all Module elements
        Poco::AutoPtr<Poco::XML::NodeList> modules =
            xmlDoc->getElementsByTagName(TskPipeline::MODULE_ELEMENT);

        if (modules->length() == 0)
        {
            LOGWARN(L"TskPipeline::initialize - No modules found in config file.");
            return;
        }

        // Size our list based on the number of modules
        m_modules.resize(modules->length());

        // Iterate through the module elements, make sure they are increasing order
        // we now allow for gaps to make it easier to comment things out.
        int prevOrder = -1;
        for (unsigned int i = 0; i < modules->length(); i++)
        {
            Poco::XML::Node * pNode = modules->item(i);
            Poco::XML::Element* pElem = dynamic_cast<Poco::XML::Element*>(pNode);
            Poco::XML::XMLString orderStr = pElem->getAttribute(TskPipeline::MODULE_ORDER_ATTR);
            if (orderStr == "") {
                throw TskException("TskPipeline::initialize: Module order missing.");
            }
            int order;
            try
            {
                order = Poco::NumberParser::parse(orderStr);
            } catch (Poco::SyntaxException ex)
            {
                std::stringstream msg;
                msg << "TskPipeline::initialize - Module order must a decimal number. Got " << orderStr.c_str();
                throw TskException(msg.str());
            }
            if (order <= prevOrder)
            {
                std::stringstream msg;
                msg << "TskPipeline::initialize - Expecting order bigger than " << prevOrder << ", got " << order;
                throw TskException(msg.str());
            }
            prevOrder = order;
        }

        // Iterate through the module elements creating a new Module for each one
        m_modules.clear();
        for (unsigned int i = 0; i < modules->length(); i++)
        {
            Poco::XML::Node * pNode = modules->item(i);
            Poco::XML::Element* pElem = dynamic_cast<Poco::XML::Element*>(pNode);

            if (!pElem)
                continue;

            // Create a new module
            TskModule * pModule = createModule(pElem);

            if (pModule == NULL)
            {
                throw TskException("TskPipeline::initialize - Module creation failed.");
            }

            if (m_loadDll)
            {
                TskImgDB& imgDB = TskServices::Instance().getImgDB();

                // Insert into Modules table
                int moduleId = 0;
                if (imgDB.addModule(pModule->getName(), pModule->getDescription(), moduleId))
                {
                    std::stringstream errorMsg;
                    errorMsg << "TskPipeline::initialize - Failed to insert into Modules table. "
                             << " module name=" << pModule->getName() ;
                    throw TskException(errorMsg.str());
                }
                else
                {
                    pModule->setModuleId(moduleId);
                    m_moduleNames.insert(std::make_pair(moduleId, pModule->getName()));
                    m_moduleExecTimes.insert(std::make_pair(moduleId, Poco::Timespan()));
                }
                bool duplicate = false;
                for (std::vector<TskModule*>::iterator it = m_modules.begin(); it != m_modules.end(); it++) {
                    if ((*it)->getModuleId() == pModule->getModuleId()) {
                        duplicate = true;
                        std::stringstream msg;
                        msg << "TskPipeline::initialize - " << pModule->getName() << " is a duplicate module. " <<
                            "The duplicate will not be added to the pipeline";
                        throw TskException(msg.str());
//.........这里部分代码省略.........
开发者ID:WalKnDude,项目名称:sleuthkit,代码行数:101,代码来源:TskPipeline.cpp


示例16: getArchivePath

/**
 * @param filenames : List of files to search
 * @param exts : List of extensions to check against
 * @return list of archive locations
 */
std::string SNSDataArchive::getArchivePath(const std::set<std::string>& filenames, const std::vector<std::string>& exts) const
{
  std::set<std::string>::const_iterator iter = filenames.begin();
  std::string filename = *iter;

  //ICAT4 web service take upper case filename such as HYSA_2662
  std::transform(filename.begin(),filename.end(),filename.begin(),toupper);

  std::vector<std::string>::const_iterator iter2 = exts.begin();
  for(; iter2!=exts.end(); ++iter2)
  {
    g_log.debug() << *iter2 << ";";
  }
  g_log.debug()  << "\n";

  std::string baseURL("http://icat.sns.gov:8080/icat-rest-ws/datafile/filename/");

  std::string URL(baseURL + filename);
  g_log.debug() << "URL: " << URL << "\n";

  Poco::URI uri(URL);
  std::string path(uri.getPathAndQuery());

  Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
  Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, path, Poco::Net::HTTPMessage::HTTP_1_1);
  session.sendRequest(req);

  Poco::Net::HTTPResponse res;
  std::istream& rs = session.receiveResponse(res);
  g_log.debug() << "res.getStatus(): " << res.getStatus() << "\n";

  // Create a DOM document from the response.
  Poco::XML::DOMParser parser;
  Poco::XML::InputSource source(rs);
  Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&source);

  std::vector<std::string> locations;

  // If everything went fine, return the XML document.
  // Otherwise look for an error message in the XML document.
  if (res.getStatus() == Poco::Net::HTTPResponse::HTTP_OK)
  {
    std::string location;
    Poco::AutoPtr<Poco::XML::NodeList> pList = pDoc->getElementsByTagName("location");
    for(unsigned long i = 0 ; i < pList->length(); i++)
    {
      location = pList->item(i)->innerText();
      g_log.debug() << "location: " << location << "\n";
      locations.push_back(location);
    }
  }
  else
  {
    std::string error(res.getReason());
    throw Poco::ApplicationException("HTTPRequest Error", error);
  }

  std::vector<std::string>::const_iterator ext = exts.begin();
  for (; ext != exts.end(); ++ext)
  {
    std::string datafile = filename + *ext;
    std::vector<std::string>::const_iterator iter = locations.begin();
    for(; iter!=locations.end(); ++iter)
    {
      if (boost::algorithm::ends_with((*iter), datafile))
      {
        return *iter;
      } // end if
    } // end for iter

  }  // end for ext
  return "";
}
开发者ID:AlistairMills,项目名称:mantid,代码行数:78,代码来源:SNSDataArchive.cpp


示例17: ParseXML

const bool MessageXML::ParseXML(const std::string &xml)
{
	bool parsed=false;
	Poco::XML::DOMParser dp;

	dp.setEntityResolver(0);

	Initialize();

	try
	{
		Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml));
		Poco::XML::Element *root=XMLGetFirstChild(doc,"Message");
		Poco::XML::Element *txt=NULL;

		txt=XMLGetFirstChild(root,"Date");
		if(txt)
		{
			if(txt->firstChild())
			{
				m_date=SanitizeSingleString(txt->firstChild()->getNodeValue());
			}
		}
		txt=XMLGetFirstChild(root,"Time");
		if(txt)
		{
			if(txt->firstChild())
			{
				m_time=SanitizeSingleString(txt->firstChild()->getNodeValue());
			}
		}
		txt=XMLGetFirstChild(root,"Subject");
		if(txt)
		{
			if(txt->firstChild())
			{
				m_subject=SanitizeSingleString(txt->firstChild()->getNodeValue());
			}
		}
		txt=XMLGetFirstChild(root,"MessageID");
		if(txt)
		{
			if(txt->firstChild())
			{
				m_messageid=SanitizeSingleString(txt->firstChild()->getNodeValue());
			}
		}
		txt=XMLGetFirstChild(root,"ReplyBoard");
		if(txt)
		{
			if(txt->firstChild())
			{
				m_replyboard=SanitizeSingleString(txt->firstChild()->getNodeValue());
				// strip off everything after , in board name
				if(m_replyboard.find(',')!=std::string::npos)
				{
					m_replyboard.erase(m_replyboard.find(','));
				}
				m_replyboard=Board::FixBoardName(m_replyboard);
			}
		}
		txt=XMLGetFirstChild(root,"Body");
		if(txt)
		{
			if(txt->firstChild())
			{
				m_body=txt->firstChild()->getNodeValue();
			}
		}
		Poco::XML::Element *boards=XMLGetFirstChild(root,"Boards");
		if(boards)
		{
			Poco::XML::Element *board=XMLGetFirstChild(boards,"Board");
			while(board)
			{
				if(board->firstChild())
				{
					std::string boardname=SanitizeSingleString(board->firstChild()->getNodeValue());
					// strip off everything after , in board name
					if(boardname.find(',')!=std::string::npos)
					{
						boardname.erase(boardname.find(','));
					}
					boardname=Board::FixBoardName(boardname);
					m_boards.push_back(boardname);
				}
				board=XMLGetNextSibling(board,"Board");
			}
		}
		Poco::XML::Element *inreplyto=XMLGetFirstChild(root,"InReplyTo");
		if(inreplyto)
		{
			Poco::XML::Element *message=XMLGetFirstChild(inreplyto,"Message");
			while(message)
			{
				Poco::XML::Element *orderel=XMLGetFirstChild(message,"Order");
				Poco::XML::Element *messageidel=XMLGetFirstChild(message,"MessageID");
				if(orderel && orderel->firstChild() && messageidel && messageidel->firstChild())
				{
					int order=-1;
//.........这里部分代码省略.........
开发者ID:steveatinfincia,项目名称:fms,代码行数:101,代码来源:messagexml.cpp


示例18: RestoreState

void DebugUtil::RestoreState()
{
    Poco::Path path;
    if (!GetPersistencePath(path)) return;

    path.setFileName(DEBUG_UTIL_XML);

    try
    {
        Poco::XML::DOMParser parser;

        Poco::FileInputStream reader(path.toString());
        Poco::XML::InputSource source(reader);

        //source.setSystemId(baseDir);
        Poco::XML::Document* doc = parser.parse(&source);
        Poco::XML::Element* debugutil = doc->documentElement();

        if (debugutil)
        {
            // restore traced objects
            Poco::XML::NodeList* elementList = debugutil->getElementsByTagName(TRACEOBJECT_TAG);
            for (std::size_t i = 0; i < elementList->length(); i++)
            {
                Poco::XML::Element* elem =
                    dynamic_cast<Poco::XML::Element*> (elementList->item(static_cast<unsigned long>(i)));

                if (!elem->hasAttribute(ID_ATTR)) continue;

                const std::string& attr = elem->getAttribute(ID_ATTR);

                int traceId = 0;
                try
                {
                    traceId = Poco::NumberParser::parse(attr);
                }
                catch (const Poco::SyntaxException& e)
                {
                    BERRY_WARN << e.displayText();
                }

                DebugUtil::TraceObject(traceId);
            }
            elementList->release();

            // restore traced classes
            elementList = debugutil->getElementsByTagName(TRACECLASS_TAG);
            for (std::size_t i = 0; i < elementList->length(); i++)
            {
                Poco::XML::Element* elem =
                    dynamic_cast<Poco::XML::Element*> (elementList->item(static_cast<unsigned long>(i)));

                if (!elem->hasAttribute(NAME_ATTR)) continue;

                const std::string& traceClass = elem->getAttribute(NAME_ATTR);
                if (!traceClass.empty())
                    DebugUtil::TraceClass(traceClass);
            }
            elementList->release();
        }

        doc->release();
    }
    catch (Poco::XML::SAXParseException& e)
    {
        BERRY_WARN << e.displayText();
    }
    catch (Poco::FileNotFoundException&)
    {

    }
    catch (Poco::FileException& e)
    {
        BERRY_WARN << e.displayText();
    }

    // restore BreakpointManager
    path.setFileName(DebugBreakpointManager::BREAKPOINTS_XML);
    GetBreakpointManager()->RestoreState(path);
}
开发者ID:robotdm,项目名称:MITK,代码行数:80,代码来源:berryDebugUtil.cpp


示例19: load

bool Configure::load(void)
{
    std::ifstream in(SystemInfo::instance().getExecutePath() + "\\config\\sys.xml");
    Poco::XML::InputSource src(in);
    Poco::XML::DOMParser parser;

    try
    {
        Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&src);
        Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ALL);
        Poco::XML::Node* pNode = it.nextNode();


        while (pNode)  
        {  
            if(pNode->nodeName() == "EncodChannel")
            {
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    continue; //No text node present
                }
                m_encodeChannel = pNode->nodeValue();
				Poco::XML::XMLString tt = Poco::XML::toXMLString(m_encodeChannel);
            }

            if(pNode->nodeName() == "InputTSPath")
            {
				getNetWorkPathAttr(pNode->attributes(),&m_inputTSPath);
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    continue; //No text node present
                }
				m_inputTSPath.path = pNode->nodeValue();
				m_inputTSPath.objectName = "o:";
            }

            if(pNode->nodeName() == "InputXMLPath")
            {
				getNetWorkPathAttr(pNode->attributes(),&m_inputXMLPath);
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    continue; //No text node present
                }
				m_inputXMLPath.path = pNode->nodeValue();
				m_inputXMLPath.objectName = "p:";
            }

            if(pNode->nodeName() == "OutputTSPath")
            {
				getNetWorkPathAttr(pNode->attributes(),&m_outputTSPath);
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    continue; //No text node present
                }
				m_outputTSPath.path = pNode->nodeValue();
				m_outputTSPath.objectName = "q:";
            }

            if(pNode->nodeName() == "OutputXMLPath")
            {
				getNetWorkPathAttr(pNode->attributes(),&m_outputXMLPath);
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    continue; //No text node present
                }
				m_outputXMLPath.path = pNode->nodeValue();
				m_outputXMLPath.objectName = "r:";
            }

            if(pNode->nodeName() == "OutputStream1")
            {
				getOutputStreamAttr(pNode->attributes(),&m_outputStream[0]);
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    continue; //No text node present
                }
            }
            if(pNode->nodeName() == "OutputStream2")
            {
				getOutputStreamAttr(pNode->attributes(),&m_outputStream[1]);
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    continue; //No text node present
                }
            }
            if(pNode->nodeName() == "OutputStream3")
            {
				getOutputStreamAttr(pNode->attributes(),&m_outputStream[2]);
                pNode = it.nextNode();
                if(pNode->nodeName() != "#text")
                {
                    continue; //No text node present
                }
//.........这里部分代码省略.........
开发者ID:zhiguangq,项目名称:hlsEncoder,代码行数:101,代码来源:Configure.cpp


示例20: readXMLGroupingFile

  /**
   * Reads detctor ids for groups from an XML grouping file, such as one created by the SpatialGrouping algorithm.
   * @param filename :: path and name of input file
   * @throw FileError is there is a problem with the XML file
   */
  void ReadGroupsFromFile::readXMLGroupingFile(const std::string& filename)
  {
    Poco::XML::DOMParser xmlParser;
    Poco::XML::Document* file;
    try
    {
      file = xmlParser.parse(filename);
    }
    catch ( ... )
    {
      throw Kernel::Exception::FileError("Unable to parse file: ", filename);
    }

    Poco::XML::Element* root = file->documentElement();
  
    if ( ! root->hasChildNodes() )
    {
      throw Kernel::Exception::FileError("No root element in XML grouping file: ", filename);
    }

    Poco::XML::NodeList* groups = root->getElementsByTagName("group");

    i 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ xml::Element类代码示例发布时间:2022-05-31
下一篇:
C++ util::OptionSet类代码示例发布时间: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