当前位置: 首页>>代码示例>>C++>>正文


C++ SAXParser类代码示例

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


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

示例1: dictionaryWithContentsOfFile

    ValueMap dictionaryWithContentsOfFile(const std::string& fileName)
    {
        _resultType = SAX_RESULT_DICT;
        SAXParser parser;

        CCASSERT(parser.init("UTF-8"), "The file format isn't UTF-8");
        parser.setDelegator(this);

        parser.parse(fileName);
        return _rootDict;
    }
开发者ID:RayRiver,项目名称:misc,代码行数:11,代码来源:CCFileUtils.cpp

示例2: arrayWithContentsOfFile

    ValueVector arrayWithContentsOfFile(const std::string& fileName)
    {
        _resultType = SAX_RESULT_ARRAY;
        SAXParser parser;

        CCASSERT(parser.init("UTF-8"), "The file format isn't UTF-8");
        parser.setDelegator(this);

        parser.parse(fileName);
        return _rootArray;
    }
开发者ID:RayRiver,项目名称:misc,代码行数:11,代码来源:CCFileUtils.cpp

示例3: dictionaryWithDataOfFile

    ValueMap dictionaryWithDataOfFile(const char* filedata, int filesize)
    {
        _resultType = SAX_RESULT_DICT;
        SAXParser parser;

        CCASSERT(parser.init("UTF-8"), "The file format isn't UTF-8");
        parser.setDelegator(this);

        parser.parse(filedata, filesize);
        return _rootDict;
    }
开发者ID:1414648814,项目名称:AStar-Cocos2dx,代码行数:11,代码来源:CCFileUtils.cpp

示例4: getFrames

 Vector<SpriteFrame*> getFrames(const std::string& fileName)
 {
     SAXParser parser;
     
     parser.init("UTF-8");
     parser.setDelegator(this);
     
     parser.parse(fileName);
     
     return _frames;
 }
开发者ID:elnormous,项目名称:cocos2d-x-ext,代码行数:11,代码来源:SpriteAnimation.cpp

示例5: tParser

TMXFile::TMXFile(const char* pPath)
{
    TMXFileParser tParser(this, pPath);
    SAXParser tSAXParser;
    tSAXParser.setDelegator(&tParser);
    tSAXParser.parse(pPath);
    if (tParser.Failed())
    {
        CHU_LOGERROR("failed to load tmx from '%s'.", pPath);
        throw std::logic_error("LoadFailed");
    }
}
开发者ID:9chu,项目名称:cocos2dx-sokoban,代码行数:12,代码来源:TMXFile.cpp

示例6: parseXMLFile

bool TMXMapInfo::parseXMLFile(const std::string& xmlFilename)
{
    SAXParser parser;
    
    if (false == parser.init("UTF-8") )
    {
        return false;
    }
    
    parser.setDelegator(this);

    return parser.parse(FileUtils::getInstance()->fullPathForFilename(xmlFilename));
}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:13,代码来源:CCTMXXMLParser.cpp

示例7: testUndeclaredNamespaceNoPrefixes

void SAXParserTest::testUndeclaredNamespaceNoPrefixes()
{
	SAXParser parser;
	parser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
	parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, false);
	try
	{
		std::string xml = parse(parser, XMLWriter::CANONICAL, UNDECLARED_NAMESPACE);
		fail("undeclared namespace - must throw exception");
	}
	catch (SAXParseException&)
	{
	}
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:14,代码来源:SAXParserTest.cpp

示例8: parseXMLString

bool TMXMapInfo::parseXMLString(const std::string& xmlString)
{
    size_t len = xmlString.size();
    if (len <= 0)
        return false;

    SAXParser parser;

    if (false == parser.init("UTF-8") )
    {
        return false;
    }

    parser.setDelegator(this);

    return parser.parse(xmlString.c_str(), len);
}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:17,代码来源:CCTMXXMLParser.cpp

示例9: ProcessError

void
OptionsIO::loadConfiguration() {
    OptionsCont& oc = OptionsCont::getOptions();
    if (!oc.exists("configuration-file") || !oc.isSet("configuration-file")) {
        return;
    }
    std::string path = oc.getString("configuration-file");
    if (!FileHelpers::exists(path)) {
        throw ProcessError("Could not find configuration '" + oc.getString("configuration-file") + "'.");
    }
    PROGRESS_BEGIN_MESSAGE("Loading configuration");
    // build parser
    SAXParser parser;
    parser.setValidationScheme(SAXParser::Val_Auto);
    parser.setDoNamespaces(false);
    parser.setDoSchema(false);
    // start the parsing
    OptionsLoader handler;
    try {
        parser.setDocumentHandler(&handler);
        parser.setErrorHandler(&handler);
        parser.parse(path.c_str());
        if (handler.errorOccured()) {
            throw ProcessError("Could not load configuration '" + path + "'.");
        }
    } catch (const XMLException& e) {
        throw ProcessError("Could not load configuration '" + path + "':\n " + TplConvert<XMLCh>::_2str(e.getMessage()));
    }
    oc.relocateFiles(path);
    PROGRESS_DONE_MESSAGE();
}
开发者ID:smendez-hi,项目名称:SUMO-hib,代码行数:31,代码来源:OptionsIO.cpp

示例10: testRSS

void SAXParserTest::testRSS()
{
	SAXParser parser;
	WhitespaceFilter filter(&parser);
	TestEntityResolver resolver;
	filter.setEntityResolver(&resolver);
	parser.setFeature(XMLReader::FEATURE_EXTERNAL_GENERAL_ENTITIES, true);
	parser.setFeature(XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES, true);
	
	std::istringstream istr(RSS);
	Poco::FileOutputStream ostr("rss.xml");
	XMLWriter writer(ostr, XMLWriter::CANONICAL | XMLWriter::PRETTY_PRINT);
	filter.setContentHandler(&writer);
	filter.setDTDHandler(&writer);
	filter.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<Poco::XML::LexicalHandler*>(&writer));
	InputSource source(istr);
	filter.parse(&source);
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:18,代码来源:SAXParserTest.cpp

示例11: handleResponse

void AreFriends::handleResponse(istream & inputstream) const
{
	SAXParser parser;
	parser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
	parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
	parser.setContentHandler(const_cast<AreFriends*>(this));
	
	try
	{
		SharedPtr<InputSource> inputSource(new InputSource(inputstream));
		parser.parse(inputSource);
		mSuccessCallback.call(mFriendInfoList);
	}
	catch (Exception& e)
	{
		cerr << e.displayText() << endl;
		mErrorCallback.call(ErrorResponse(0,e.message(), KeyValue()));
	}
}
开发者ID:boodjoom,项目名称:stacked-crooked,代码行数:19,代码来源:AreFriends.cpp

示例12: Clear

/* Read the file. */
bool GQCFileData::Read(const std::string &fileName)
{
    Clear();

	// Initialize the XML4C2 system
	try
	{
		XMLPlatformUtils::Initialize();
	}
	catch (const XMLException&)
	{
		return false;
	}

	bool status = false;
	SAXParser* parser = new SAXParser;
	parser->setValidationScheme(SAXParser::Val_Never);
	parser->setLoadExternalDTD(false);
	parser->setDoNamespaces(false);
	parser->setDoSchema(false);
	parser->setValidationSchemaFullChecking(false);
	SAXGenericReportHandlers handler(this);
	parser->setDocumentHandler(&handler);
	parser->setErrorHandler(&handler);
	try
	{
		parser->parse(fileName.c_str());
		int errorCount = parser->getErrorCount();
		if (errorCount == 0)
		{
			status = true;
		}
	}
	catch (...)
	{
		status = false;
	}
	delete parser;
	XMLPlatformUtils::Terminate();
	return status;
}
开发者ID:HenrikBengtsson,项目名称:Affx-Fusion-SDK,代码行数:42,代码来源:GQCFileData.cpp

示例13: main

int main(int argc, char** argv)
{
	// parse an XML document and print the generated SAX events

	if (argc < 2)
	{
		std::cout << "usage: " << argv[0] << ": <xmlfile>" << std::endl;
		return 1;
	}
	
	MyHandler handler;

	SAXParser parser;
	parser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
	parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
	parser.setContentHandler(&handler);
	parser.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<LexicalHandler*>(&handler));
	
	try
	{
		parser.parse(argv[1]);
	}
	catch (Poco::Exception& e)
	{
		std::cerr << e.displayText() << std::endl;
		return 2;
	}
	
	return 0;
}
开发者ID:12307,项目名称:poco,代码行数:30,代码来源:SAXParser.cpp

示例14: return

int InstallationParser::parse() {
  if (initialization() == 1) // Problem during the initialisation.
    return(1);

  SAXParser* parser = new SAXParser();
  parser->setDoValidation(true);
  parser->setDoNamespaces(true);

  InstallationSAXHandler* handler = new InstallationSAXHandler();
  parser->setDocumentHandler(handler);
  parser->setErrorHandler(handler);
  try {
    const char* file = xmlFile.c_str(); // Name of the descriptor file in the current directory.
    parser->parse(file); // Parsing procedure.
    handler->get_pkgname(pkgname); // Result of the parsing.
	handler->get_pkgUUID(pkgUUID);
	handler->get_implementations(codefiles); // Result of the parsing.
  }
  catch (const XMLException& toCatch) { // File not found for the parsing.
    std::cerr << "\nFile not found : '" << xmlFile << "'\n";
    std::cerr << "Exception message is : \n" << toCatch.getMessage() << "\n";
    return(4);
  }
  int err = handler->get_error(); // The error codes are got from the handler object.
  delete(handler); // Object deleted.
  delete(parser); // Object deleted.
  return(err); // 0, 2 or 3 is returned.
}
开发者ID:BackupTheBerlios,项目名称:qedo,代码行数:28,代码来源:InstallationParser.cpp

示例15: init_xml_dom

bool
Kumu::XMLElement::ParseString(const char* document, ui32_t doc_len)
{
  if ( doc_len == 0 )
    return false;

  init_xml_dom();

  int errorCount = 0;
  SAXParser* parser = new SAXParser();

  parser->setValidationScheme(SAXParser::Val_Always);
  parser->setDoNamespaces(true);    // optional

  MyTreeHandler* docHandler = new MyTreeHandler(this);
  parser->setDocumentHandler(docHandler);
  parser->setErrorHandler(docHandler);

  try
    {
      MemBufInputSource xmlSource(reinterpret_cast<const XMLByte*>(document),
				  static_cast<const unsigned int>(doc_len),
				  "pidc_rules_file");

      parser->parse(xmlSource);
    }
  catch (const XMLException& e)
    {
      char* message = XMLString::transcode(e.getMessage());
      DefaultLogSink().Error("Parser error: %s\n", message);
      XMLString::release(&message);
      errorCount++;
    }
  catch (const SAXParseException& e)
    {
      char* message = XMLString::transcode(e.getMessage());
      DefaultLogSink().Error("Parser error: %s at line %d\n", message, e.getLineNumber());
      XMLString::release(&message);
      errorCount++;
    }
  catch (...)
    {
      DefaultLogSink().Error("Unexpected XML parser error\n");
      errorCount++;
    }
  
  if ( errorCount == 0 )
    m_NamespaceOwner = (void*)docHandler->TakeNamespaceMap();

  delete parser;
  delete docHandler;

  return errorCount > 0 ? false : true;
}
开发者ID:SeanFarinha,项目名称:opendcp,代码行数:54,代码来源:KM_xml.cpp


注:本文中的SAXParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。