Ejemplo n.º 1
0
    bool Version::operator < (Version ver) {
        //Version string could have a wide variety of formats. Use regex to choose specific comparison types.

        regex reg1("(\\d+\\.?)+");  //a.b.c.d.e.f.... where the letters are all integers, and 'a' is the shortest possible match.

        //boost::regex reg2("(\\d+\\.?)+([a-zA-Z\\-]+(\\d+\\.?)*)+");  //Matches a mix of letters and numbers - from "0.99.xx", "1.35Alpha2", "0.9.9MB8b1", "10.52EV-D", "1.62EV" to "10.0EV-D1.62EV".

        if (regex_match(verString, reg1) && regex_match(ver.AsString(), reg1)) {
            //First type: numbers separated by periods. If two versions have a different number of numbers, then the shorter should be padded
            //with zeros. An arbitrary number of numbers should be supported.
            istringstream parser1(verString);
            istringstream parser2(ver.AsString());
            while (parser1.good() || parser2.good()) {
                //Check if each stringstream is OK for i/o before doing anything with it. If not, replace its extracted value with a 0.
                uint32_t n1, n2;
                if (parser1.good()) {
                    parser1 >> n1;
                    parser1.get();
                } else
Ejemplo n.º 2
0
	bool Scene::UnSerialize(DataStream* pStream)
	{
		uint32 v = pStream->ReadInt32();

		if(Version(v) != g_scene_file_version)
		{
			logger() << ("invalid scene file version:") << "\n";
			logger() << "should be:" << g_scene_file_version.AsString() << "\n";
			logger() <<"file version:" << Version(v).AsString() << "\n";

			return false;
		}

		if(false == UnSerializeObject(m_pRoot, pStream))
		{
			return false;
		}
		EventPtr pEvent = alloc_object<Event, uint32>(EV_SCENE_LOADED);
		m_pObjectManager->DispatchEvent(pEvent);

		return true;
	}