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


C++ istream::imbue方法代码示例

本文整理汇总了C++中std::istream::imbue方法的典型用法代码示例。如果您正苦于以下问题:C++ istream::imbue方法的具体用法?C++ istream::imbue怎么用?C++ istream::imbue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::istream的用法示例。


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

示例1: file

Base::XMLReader::XMLReader(const char* FileName, std::istream& str) 
  : DocumentSchema(0), ProgramVersion(""), FileVersion(0), Level(0),
    CharacterCount(0), ReadType(None), _File(FileName), _valid(false),
    _verbose(true)
{
#ifdef _MSC_VER
    str.imbue(std::locale::empty());
#else
    //FIXME: Check whether this is correct
    str.imbue(std::locale::classic());
#endif

    // create the parser
    parser = XMLReaderFactory::createXMLReader();
    //parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, false);
    //parser->setFeature(XMLUni::fgXercesSchema, false);
    //parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
    //parser->setFeature(XMLUni::fgXercesIdentityConstraintChecking, false);
    //parser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, false);
    //parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
    //parser->setFeature(XMLUni::fgXercesDynamic, true);

    parser->setContentHandler(this);
    parser->setLexicalHandler(this);
    parser->setErrorHandler(this);

    try {
        StdInputSource file(str, _File.filePath().c_str());
        _valid = parser->parseFirst(file, token);
    }
    catch (const XMLException& toCatch) {
        char* message = XMLString::transcode(toCatch.getMessage());
        cerr << "Exception message is: \n"
             << message << "\n";
        XMLString::release(&message);
    }
    catch (const SAXParseException& toCatch) {
        char* message = XMLString::transcode(toCatch.getMessage());
        cerr << "Exception message is: \n"
             << message << "\n";
        XMLString::release(&message);
    }
#ifndef FC_DEBUG
    catch (...) {
        cerr << "Unexpected Exception \n";
    }
#endif
}
开发者ID:DeepSOIC,项目名称:FreeCAD-ellipse,代码行数:48,代码来源:Reader.cpp

示例2: Parser

bool CConfigurationFile::CXML::load(std::istream & is,
                                    const std::string & relativeTo)
{
  mPWD = relativeTo;

  is.imbue(std::locale::classic());
  is.precision(16);

  mpIstream = &is;
  bool success = true;
  bool done = false;

  CVersion Version;
  CCopasiXMLParser Parser(Version);

#define BUFFER_SIZE 0xfffe
  char * pBuffer = new char[BUFFER_SIZE + 1];

  while (!done)
    {
      mpIstream->get(pBuffer, BUFFER_SIZE, 0);

      if (mpIstream->eof()) done = true;

      if (mpIstream->fail() && !done)
        {
          std::string ConfigFile;
          COptions::getValue("ConfigFile", ConfigFile);
          CCopasiMessage Message(CCopasiMessage::WARNING, MCConfiguration + 2, ConfigFile.c_str());

          done = true;
          success = false;
        }

      if (!Parser.parse(pBuffer, -1, done))
        {
          CCopasiMessage Message(CCopasiMessage::RAW, MCXML + 2,
                                 Parser.getCurrentLineNumber(),
                                 Parser.getCurrentColumnNumber(),
                                 Parser.getErrorString());
          done = true;
          success = false;
        }
    }

  delete [] pBuffer;
#undef BUFFER_SIZE

  if (success && Parser.getCurrentGroup() != NULL)
    {
      mConfiguration = * Parser.getCurrentGroup();
      mConfiguration.setObjectName("Configuration");

      delete Parser.getCurrentGroup();
    }
  else
    mConfiguration.clear();

  return success;
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:60,代码来源:CConfigurationFile.cpp

示例3: readObject

        virtual ReadResult readObject(std::istream& fin, const Options* options) const
        {
            loadWrappers();

            fin.imbue(std::locale::classic());

            Input fr;
            fr.attach(&fin);
            fr.setOptions(options);

            typedef std::vector<osg::Object*> ObjectList;
            ObjectList objectList;

            // load all nodes in file, placing them in a group.
            while(!fr.eof())
            {
                Object *object = fr.readObject();
                if (object) objectList.push_back(object);
                else fr.advanceOverCurrentFieldOrBlock();
            }

            if  (objectList.empty())
            {
                return ReadResult("No data loaded");
            }
            else if (objectList.size()==1)
            {
                return objectList.front();
            }
            else
            {
                return objectList.front();
            }
        }
开发者ID:AlexBobkov,项目名称:OpenSceneGraph,代码行数:34,代码来源:ReaderWriterOSG.cpp

示例4: read

/**
 * Read data from a file. Only DT_MAP is tested. With an array it is hard to set the
 * size beforehand properly (except if you know what to retrieve).
 */
void DataContainer::read(std::istream& in) { //, DataDecoratorType resolution) {
	DataDecoratorType x;
	switch(dataType) {
	case DT_MAP:
		assert (map_data != NULL);
		map_data->clear();
		int y;
		in.imbue(std::locale(std::locale(), new colonsep));

		while(in >> x >> y) {
//			if (resolution > 0) {
//				int x_ins = (int)(x * resolution);
//				x = x_ins / (DataDecoratorType)resolution;
//			}
			map_data->insert(make_pair<DataDecoratorType,int>(x, y));
			assert(y != 0);
//			cout << "x and y: " << x << " and " << y << endl;
		}
//		cout << "Read " << map_data->size() << " items" << endl;
		break;
	case DT_F2DARRAY:
		assert (float_data != NULL);
		int ix;
		float fy;
		in.imbue(std::locale(std::locale(), new colonsep));
		while(in >> ix >> fy) {
			if (ix >= float_data_len) {
				cerr << "Array is not large enough (" << float_data_len << ")" << endl;
				break;
			}
			float_data[ix] = fy;
			cout << "x and y: " << ix << " and " << fy << endl;
		}
		break;

	default:
		cerr << "Read: Unknown data type" << endl;
	}
}
开发者ID:mrquincle,项目名称:aim_modules,代码行数:43,代码来源:DataDecorator.cpp

示例5: ins

osgDB::ReaderWriter::ReadResult ReaderWriterVDPM::readNode(std::istream& fin, const Options* options) const
{
    if (fin)
    {
        fin.imbue(std::locale::classic());

        vdpm::StdInStream ins(&fin);
        vdpm::SRMesh* srmesh = vdpm::Serializer::getInstance().loadSRMesh(ins);

        osg::Node* node = convertSRMeshToSceneGraph(*srmesh, options);
        return node;
    }

    return ReadResult::FILE_NOT_HANDLED;
}
开发者ID:wangfeilong321,项目名称:vdpm,代码行数:15,代码来源:ReaderWriterVDPM.cpp

示例6: readNode

        virtual ReadResult readNode(std::istream& fin, const Options* options) const
        {
            loadWrappers();

            fin.imbue(std::locale::classic());

            Input fr;
            fr.attach(&fin);
            fr.setOptions(options);

            typedef std::vector<osg::Node*> NodeList;
            NodeList nodeList;

            // load all nodes in file, placing them in a group.
            while(!fr.eof())
            {
                Node *node = fr.readNode();
                if (node) nodeList.push_back(node);
                else fr.advanceOverCurrentFieldOrBlock();
            }

            if  (nodeList.empty())
            {
                return ReadResult("No data loaded");
            }
            else if (nodeList.size()==1)
            {
                return nodeList.front();
            }
            else
            {
                Group* group = new Group;
                group->setName("import group");
                for(NodeList::iterator itr=nodeList.begin();
                    itr!=nodeList.end();
                    ++itr)
                {
                    group->addChild(*itr);
                }
                return group;
            }

        }
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:43,代码来源:ReaderWriterOSG.cpp

示例7: readNode

        virtual osgDB::ReaderWriter::ReadResult readNode(std::istream& fin, const Options* options) const
        {
            fin.imbue(std::locale::classic());

            osgDB::Input fr;
            fr.attach(&fin);
            fr.setOptions(options);

            osg::ref_ptr<osg::Group> group = new osg::Group;

            while(!fr.eof())
            {

                bool itrAdvanced = false;

                if (fr.matchSequence("file %s") || fr.matchSequence("file %w") )
                {
                    osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile(fr[1].getStr());

                    if (node) group->addChild(node);

                    fr += 2;
                    itrAdvanced = true;
                }

                osg::ref_ptr<osg::Node> node = fr.readNode();
                if (node.valid())
                {
                    group->addChild(node);
                    itrAdvanced = true;
                }

                if (!itrAdvanced)
                {
                    if (fr[0].getStr()) { OSG_NOTICE<<"Terrain file - unreconised token : "<<fr[0].getStr() <<""<< std::endl; }
                    ++fr;
                }
            }

            if (group->getNumChildren()>0) return group;
            else return 0;
        }
开发者ID:AlexBobkov,项目名称:OpenSceneGraph,代码行数:42,代码来源:ReaderWriterOsgTerrain.cpp


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