EStatusCode Type1ToCFFEmbeddedFontWriter::AddDependentGlyphs(StringVector& ioSubsetGlyphIDs)
{
	EStatusCode status = PDFHummus::eSuccess;
	StringSet glyphsSet;
	StringVector::iterator it = ioSubsetGlyphIDs.begin();
	bool hasCompositeGlyphs = false;

	for(;it != ioSubsetGlyphIDs.end() && PDFHummus::eSuccess == status; ++it)
	{
		bool localHasCompositeGlyphs;
		status = AddComponentGlyphs(*it,glyphsSet,localHasCompositeGlyphs);
		hasCompositeGlyphs |= localHasCompositeGlyphs;
	}

	if(hasCompositeGlyphs)
	{
		StringSet::iterator itNewGlyphs;

		for(it = ioSubsetGlyphIDs.begin();it != ioSubsetGlyphIDs.end(); ++it)
			glyphsSet.insert(*it);

		ioSubsetGlyphIDs.clear();
		for(itNewGlyphs = glyphsSet.begin(); itNewGlyphs != glyphsSet.end(); ++itNewGlyphs)
			ioSubsetGlyphIDs.push_back(*itNewGlyphs);
		
		sort(ioSubsetGlyphIDs.begin(),ioSubsetGlyphIDs.end());
	}	
	return status;	
}
예제 #2
0
// Split a string ==========================================================
int splitString(const String& input,
                const String& delimiter,
                StringVector & results,
                bool includeEmpties)
{
    results.clear();
    size_t delimiterSize = delimiter.size();
    if (input.size()== 0 || delimiterSize == 0)
        return 0;

    size_t newPos, iPos = 0;
    String emptyString;
    while ((newPos = input.find(delimiter, iPos))!=String::npos)
    {
        if (newPos==iPos)
        {
            if (includeEmpties)
                results.push_back(emptyString);
        }
        else
            results.push_back(input.substr(iPos, newPos-iPos));
        iPos = newPos+delimiterSize;
    }
    if (iPos>=input.size())
    {
        if (includeEmpties)
            results.push_back(emptyString);
    }
    else
        results.push_back(input.substr(iPos, String::npos));
    return results.size();
}
예제 #3
0
static void parseStringVector(const std::string& str, StringVector& res)
{
  res.clear();
  std::string item;
  bool inQuotes = 0;
  for(std::string::size_type i = 0;i < str.length();i++)
    {
      if (!inQuotes && str[i] == ':')
	{
	  res.push_back(item);
	  item.erase();
	  continue;
	}
      if (!inQuotes && str[i] == '\"')
	{
	  inQuotes = 1;
	  continue;
	}
      if (inQuotes && str[i] == '\"')
	{
	  if (i + 1 < str.length() && str[i + 1] == '\"')
	    {
	      item += "\"";
	      i++;
	      continue;
	    }
	  inQuotes = 0;
	  continue;
	}
      item += str[i];
    }
  if (!res.empty() || !item.empty())
    res.push_back(item);
}
예제 #4
0
void loadPlaybackData(PlaybackVector &pv, const char *filename)
{
	StringVector sv;
	readFile(sv, filename);
	parsePlaybackData(pv, sv);
	sv.clear();
}
예제 #5
0
파일: Corpus.cpp 프로젝트: estnltk/pfe
Document readDocFromStream(std::istream& is, std::string& docName) {
    Document document;
    StringVector word;

    std::string line;
    std::string token;

    std::getline(is, docName);
    std::getline(is, line);
    while (!is.eof() && !is.fail()) {
        if (line.size() == 0) {
            break;
        }
        std::stringstream ls(line);
        std::getline(ls, token, '\t');
        while (!ls.eof()) {
            std::getline(ls, token, '\t');
            word.push_back(token);
        }
        document.push_back(word);
        word.clear();

        std::getline(is, line);
    }
    return document;
}
예제 #6
0
void OgreSample8App::setupModes()
{
    StringVector matNames;

    matNames.push_back("Examples/BumpMapping/MultiLight");
    matNames.push_back("Examples/BumpMapping/MultiLightSpecular");
    matNames.push_back("Examples/OffsetMapping/Specular");
    matNames.push_back("Examples/ShowUV");
    matNames.push_back("Examples/ShowNormals");
    matNames.push_back("Examples/ShowTangents");

    matNames.push_back("RTSS/NormalMapping_SinglePass");
    matNames.push_back("RTSS/NormalMapping_MultiPass");

    mPossibilities["ogrehead.mesh"] = matNames;
    mPossibilities["knot.mesh"] = matNames;

    matNames.clear();
    matNames.push_back("Examples/Athene/NormalMapped");
    matNames.push_back("Examples/Athene/NormalMappedSpecular");
    matNames.push_back("Examples/Athene/NormalMappedSpecular");
    matNames.push_back("Examples/ShowUV");
    matNames.push_back("Examples/ShowNormals");
    matNames.push_back("Examples/ShowTangents");
    matNames.push_back("RTSS/Athene/NormalMapping_SinglePass");
    matNames.push_back("RTSS/Athene/NormalMapping_MultiPass");

    mPossibilities["athene.mesh"] = matNames;

    for (std::map<Ogre::String,Ogre::StringVector>::iterator it = mPossibilities.begin(); it != mPossibilities.end(); it++)
    {
        Ogre::MeshPtr mesh = MeshManager::getSingleton().load(it->first,ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);

        unsigned short src,dest;
        if (!mesh->suggestTangentVectorBuildParams(VES_TANGENT,src,dest))
        {
            mesh->buildTangentVectors(VES_TANGENT,src,dest);
        }
        Entity* ent = mSceneMgr->createEntity(mesh->getName(),mesh->getName());
        ent->setMaterialName(it->second.front());
    }

    mMeshMenu->addItem(new CEGUI::ListboxTextItem("athene.mesh"));
    mMeshMenu->addItem(new CEGUI::ListboxTextItem("ogrehead.mesh"));
    mMeshMenu->addItem(new CEGUI::ListboxTextItem("knot.mesh"));
    mMeshMenu->setItemSelectState(size_t(0),true);

    const char * a = mMeshMenu->getSelectedItem()->getText().c_str();
    Ogre::StringVector::iterator it = mPossibilities[a].begin();
    Ogre::StringVector::iterator itEnd = mPossibilities[mMeshMenu->getSelectedItem()->getText().c_str()].end();

    for (; it != itEnd; it++)
    {
        mMaterialMenu->addItem(new ListboxTextItem(it->c_str()));
    }
    mMaterialMenu->setItemSelectState(size_t(0),true);
    mSceneMgr->getEntity(mMeshMenu->getSelectedItem()->getText().c_str())->setMaterialName(mMaterialMenu->getSelectedItem()->getText().c_str());
}
	ERMsg CUINewBrunswick::GetFileList(size_t n, StringVector& fileList, CCallback& callback)const
	{
		ERMsg msg;

		fileList.clear();

		if (msg)
		{

			if (n == FIRE)
			{
				ASSERT(false);
			}
			else if (n == AGRI)
			{
				CInternetSessionPtr pSession;
				CHttpConnectionPtr pConnection;

				msg = GetHttpConnection(SERVER_NAME[AGRI], pConnection, pSession, PRE_CONFIG_INTERNET_ACCESS);
				if (msg)
				{
					string str;
					msg = UtilWWW::GetPageText(pConnection, "010-001/archive.aspx", str);
					if (msg)
					{
						string::size_type pos1 = str.find("<select");
						string::size_type pos2 = str.find("</select>");

						if (pos1 != string::npos && pos2 != string::npos)
						{
							string xml_str = "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n" + str.substr(pos1, pos2 - pos1 + 9);
							zen::XmlDoc doc = zen::parse(xml_str);

							zen::XmlIn in(doc.root());
							for (zen::XmlIn it = in["option"]; it; it.next())
							{
								string value;
								//it(value);
								it.get()->getAttribute("value", value);
								fileList.push_back(value);
							}//for all station
						}
						
						//static const char* STATIONS[19] = { "47", "49", "62", "42", "45", "51", "55", "36", "37", "59", "41", "67", "68", "70", "66", "65", "53", "73", "69" };
						//for (int i = 0; i < 19; i++)
						//fileList.push_back(STATIONS[i]);
					}

					//clean connection
					pConnection->Close();
					pSession->Close();
				}
			}
		}

		return msg;
	}
예제 #8
0
파일: SynanDash.cpp 프로젝트: deNULL/seman
void InitCopulList(StringVector& v_CopulList)
{
	v_CopulList.clear();
	v_CopulList.push_back("как");
	v_CopulList.push_back("словно");
	v_CopulList.push_back("будто");
	v_CopulList.push_back("что");
	v_CopulList.push_back("точно");
}
	ERMsg CEnvCanGribForecast::GetStationList(StringVector& stationList, CCallback& callback)
	{
		ERMsg msg;

		stationList.clear();
		//msg.ajoute("Can't extract station from grid");
		//msg.ajoute("Can be used only as forecast extraction");

		return msg;
	}
예제 #10
0
// ETH@06092010 Test added to help with gcc debug.
TEST(Table, Trim) {
  Table t;
  StringVector row;

  // create table that can be trimmed
  t.appendRow(row);
  t.appendRow(row);
  row.push_back("real row 1"); row.push_back("header"); row.push_back("");
  t.appendRow(row); row.clear();
  row.push_back("real row 2"); row.push_back("2");
  t.appendRow(row); row.clear();
  t.appendRow(row);
  EXPECT_EQ(static_cast<unsigned>(5),t.nRows());
  EXPECT_EQ(static_cast<unsigned>(3),t.nCols());

  // trim and test
  t.trim();
  EXPECT_EQ(static_cast<unsigned>(2),t.nRows());
  EXPECT_EQ(static_cast<unsigned>(2),t.nCols());
}
예제 #11
0
GUIDECRAFT_BEGIN_NAMESPACE

void Action::getActionNames(StringVector& res) const
{
  assert(m_action);
  res.clear();
  GError* err = NULL;
  const int count = atspi_action_get_n_actions(m_action, &err);
  for(int i = 0;i < count;++i)
    res.push_back(atspi_action_get_action_name(m_action, i, &err));
}
예제 #12
0
bool CLemmatizer::LemmatizeWordForPlmLines(string& InputWordStr, const bool cap, const bool predict,  StringVector& results) const 
{
	results.clear();
	vector<CAutomAnnotationInner>	FindResults;

	FilterSrc(InputWordStr);

	bool bFound = LemmatizeWord(InputWordStr, cap, predict, FindResults, true);

	AssignWeightIfNeed(FindResults);

	return  FormatResults(InputWordStr, FindResults, results, bFound);
}
예제 #13
0
bool HapgenUtil::makeFlankingHaplotypes(const HapgenAlignment& aln,
                                        const ReadTable* pRefTable,
                                        int flanking,
                                        const StringVector& inHaplotypes,
                                        StringVector& outFlankingHaplotypes,
                                        StringVector& outHaplotypes)
{
    std::string upstream;
    std::string referenceHaplotype;
    std::string downstream;

    extractReferenceSubstrings(aln, pRefTable, flanking, upstream, referenceHaplotype, downstream);

    // Flip reference strings to match the strand of the input haplotypes
    if(aln.isRC)
    {
        // reverse complement each string
        upstream = reverseComplement(upstream);
        referenceHaplotype = reverseComplement(referenceHaplotype);
        downstream = reverseComplement(downstream);

        // Swap up and downstream
        upstream.swap(downstream);
    }

    // Make the reference haplotype w/ flanking sequence
    std::string referenceFlanking = upstream + referenceHaplotype + downstream;
    outFlankingHaplotypes.push_back(referenceFlanking);
    outHaplotypes.push_back(referenceHaplotype);

    // Check that all sequences match the reference haplotype properly
    bool checkOk = checkAlignmentsAreConsistent(referenceFlanking, inHaplotypes);
    if(!checkOk)
    {
        outHaplotypes.clear();
        return false;
    }

    // Make the flanking sequences for each haplotype
    for(size_t i = 0; i < inHaplotypes.size(); ++i)
    {
        // Skip if the input haplotype exactly matches the reference
        if(inHaplotypes[i] != referenceHaplotype)
        {
            outFlankingHaplotypes.push_back(upstream + inHaplotypes[i] + downstream);
            outHaplotypes.push_back(inHaplotypes[i]);
        }
    }

    return true;
}
예제 #14
0
void InitThesList (const CThesaurus* Thes, string ConceptStr,	StringVector& Vec)
{
	Vec.clear();
	vector<int> LowerTermins;
	Thes->QueryLowerTermins(ConceptStr.c_str(), morphRussian, LowerTermins);
	long Count = LowerTermins.size();
	for (long i=0; i <Count; i++)
	{
			const CInnerTermin& T = Thes->m_Termins[LowerTermins[i]];
			string TerminStr =  T.m_TerminStr;
			EngRusMakeUpper(TerminStr);
			Vec.push_back(TerminStr);
	};
	sort(Vec.begin(),Vec.end());
};
예제 #15
0
uint32 split(const String &str, const String &separators, StringVector &v, bool skipEmpty)
{
	v.clear();

	typedef boost::tokenizer<boost::char_separator<uchar>, String::const_iterator, String> tokenizer_type;

	tokenizer_type tokenizer(str, boost::char_separator<uchar>(separators.c_str()));
	for(tokenizer_type::iterator i = tokenizer.begin(); i  != tokenizer.end(); ++i)
	{
		if(skipEmpty && (*i).empty())
			continue;

		v.push_back(*i);
	}

	return static_cast<uint32>(v.size());
}
예제 #16
0
// Tokenize a C++ string ===================================================
void tokenize(const String& str, StringVector& tokens,
              const String& delimiters)
{
    tokens.clear();
    // Skip delimiters at beginning.
    String::size_type lastPos = str.find_first_not_of(delimiters, 0);
    // Find first "non-delimiter".
    String::size_type pos     = str.find_first_of(delimiters, lastPos);

    while (String::npos != pos || String::npos != lastPos)
    {
        // Found a token, add it to the vector.
        tokens.push_back(str.substr(lastPos, pos - lastPos));
        // Skip delimiters.  Note the "not_of"
        lastPos = str.find_first_not_of(delimiters, pos);
        // Find next "non-delimiter"
        pos = str.find_first_of(delimiters, lastPos);
    }
}
예제 #17
0
파일: Tokenizer.cpp 프로젝트: Arkshine/NS
int Tokenizer::split(const string& input, const string& delimiters, StringVector& result, char quoteChar)
{
    int subStart = 0;
    int subEnd = 0;
    int length = 0;
    
    result.clear();   // erase result before we start
    
    while (true)
    {
        if ((subStart = input.find_first_not_of(delimiters, subEnd)) == string::npos)
            break;
        
        // if we're handling quotes
        if (quoteChar && (input[subStart] == quoteChar))
        {
            ++subStart;                   // skip the open quote
            // have to turn quoteChar into a string for find_first_of
            if ((subEnd = input.find_first_of(string(1, quoteChar), subStart))
                == string::npos)
            {
                subEnd = input.size();
                length = subEnd - subStart;
            }
            else
            {
                // subStart has already been incremented to skip the open quote;
                // subEnd excludes the close quote; so we do NOT have to tweak the
                // difference to get a count of the characters between them.
                length = subEnd - subStart;
                ++subEnd;                   // now skip the close quote
            }
        }
        else
        {
            if ((subEnd = input.find_first_of(delimiters, subStart)) == string::npos)
                subEnd = input.size();
            length = subEnd - subStart;
        }
        result.push_back(input.substr(subStart, length));
    }
    return result.size();
}
예제 #18
0
    //-----------------------------------------------------------------------------------
    void HlmsJsonCompute::loadJobs( const rapidjson::Value &json, const HlmsJson::NamedBlocks &blocks )
    {
        HlmsCompute *hlmsCompute = mHlmsManager->getComputeHlms();

        StringVector pieceFiles;

        rapidjson::Value::ConstMemberIterator itJob = json.MemberBegin();
        rapidjson::Value::ConstMemberIterator enJob = json.MemberEnd();

        while( itJob != enJob )
        {
            if( itJob->value.IsObject() )
            {
                const String jobName( itJob->name.GetString(), itJob->name.GetStringLength() );
                pieceFiles.clear();

                rapidjson::Value::ConstMemberIterator itor = itJob->value.FindMember( "pieces" );
                if( itor != itJob->value.MemberEnd() && itor->value.IsString() )
                    pieceFiles.push_back( itor->value.GetString() );
                else if( itor != itJob->value.MemberEnd() && itor->value.IsArray() )
                {
                    const rapidjson::Value &jsonArray = itor->value;
                    for( rapidjson::SizeType i=0; i<jsonArray.Size(); ++i )
                    {
                        if( jsonArray[i].IsString() )
                            pieceFiles.push_back( jsonArray[i].GetString() );
                    }
                }

                itor = itJob->value.FindMember( "source" );
                if( itor != itJob->value.MemberEnd() && itor->value.IsString() )
                {
                    HlmsComputeJob *job = hlmsCompute->createComputeJob( jobName, jobName,
                                                                         itor->value.GetString(),
                                                                         pieceFiles );
                    loadJob( itJob->value, blocks, job, jobName );
                }
            }

            ++itJob;
        }
    }
예제 #19
0
파일: CUtil.cpp 프로젝트: geminijun/DR
/*!
* For a given directory name, extract all the files from that directory as well as
* from all its sub-directories and store the filenames in the fileList vector.
*
* \param folder folder to list
* \param fileExtList list of file extensions to search
* \param fileList list of files in folder
* \param symLinks follow Unix links?
*
* \return path exists and is a directory
*/
bool CUtil::ListAllFiles(string &folder, StringVector &fileExtList, StringVector &fileList, bool symLinks)
{
    StringVector tmpList;
    string file;
    size_t i, n;

    folder = CUtil::TrimString(folder);

#ifdef UNIX
    // skip links if user specified
    struct stat inodeData;
    if (!symLinks && (lstat(folder.c_str(), &inodeData) < 0 || S_ISLNK(inodeData.st_mode)))
        return(false);
#endif

    // process folder
    if (!GetFileList(tmpList, folder, symLinks))
        return(false);

    // read through tmpList and get the names of all the files in the directory mentioned
    for (n = 0; n < tmpList.size(); n++)
    {
        file = tmpList.at(n);

        // if no-extension filtering, each file is pushed into the fileList
        if (fileExtList.at(0) == "*.*" || fileExtList.at(0) == "*")
            fileList.push_back(file);
        else
        {
            // for each extension, if file extension matches with the extension, the file is pushed into the fileList
            for (i = 0; i < fileExtList.size(); i++)
            {
                if (MatchFilename(ExtractFilename(file), fileExtList.at(i)))
                    fileList.push_back(file);
            }
        }
    }
    tmpList.clear();
    return(true);
}
예제 #20
0
 void GetTextureNamesFromMaterial(Ogre::MaterialPtr material, StringVector& textures)
 {
     textures.clear();
     if (material.isNull())
         return;
     
     // Use a set internally to avoid duplicates
     std::set<std::string> textures_set;
     
     Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
     while(iter.hasMoreElements())
     {
         Ogre::Technique *tech = iter.getNext();
         assert(tech);
         Ogre::Technique::PassIterator passIter = tech->getPassIterator();
         while(passIter.hasMoreElements())
         {
             Ogre::Pass *pass = passIter.getNext();
             
             Ogre::Pass::TextureUnitStateIterator texIter = pass->getTextureUnitStateIterator();
             
             while(texIter.hasMoreElements())
             {
                 Ogre::TextureUnitState *texUnit = texIter.getNext();
                 const std::string& texname = texUnit->getTextureName();
                 
                 if (!texname.empty())
                     textures_set.insert(texname);
             }
         }
     }
     
     std::set<std::string>::iterator i = textures_set.begin();
     
     while (i != textures_set.end())
     {
         textures.push_back(*i);
         ++i;
     }
 }
예제 #21
0
파일: materials.cpp 프로젝트: TheSumm/rme
bool Materials::loadExtensions(FileName directoryName, wxString& error, wxArrayString& warnings)
{
	directoryName.Mkdir(0755, wxPATH_MKDIR_FULL); // Create if it doesn't exist

	wxDir ext_dir(directoryName.GetPath());
	if(!ext_dir.IsOpened()) {
		error = "Could not open extensions directory.";
		return false;
	}

	wxString filename;
	if(!ext_dir.GetFirst(&filename)) {
		// No extensions found
		return true;
	}

	StringVector clientVersions;
	do {
		FileName fn;
		fn.SetPath(directoryName.GetPath());
		fn.SetFullName(filename);
		if(fn.GetExt() != "xml") {
			continue;
		}

		pugi::xml_document doc;
		pugi::xml_parse_result result = doc.load_file(fn.GetFullPath().mb_str());
		if(!result) {
			warnings.push_back("Could not open " + filename + " (file not found or syntax error)");
			continue;
		}

		pugi::xml_node extensionNode = doc.child("materialsextension");
		if(!extensionNode) {
			warnings.push_back(filename + ": Invalid rootheader.");
			continue;
		}

		pugi::xml_attribute attribute;
		if(!(attribute = extensionNode.attribute("name"))) {
			warnings.push_back(filename + ": Couldn't read extension name.");
			continue;
		}

		const std::string& extensionName = attribute.as_string();
		if(!(attribute = extensionNode.attribute("author"))) {
			warnings.push_back(filename + ": Couldn't read extension name.");
			continue;
		}

		const std::string& extensionAuthor = attribute.as_string();
		if(!(attribute = extensionNode.attribute("description"))) {
			warnings.push_back(filename + ": Couldn't read extension name.");
			continue;
		}

		const std::string& extensionDescription = attribute.as_string();
		if(extensionName.empty() || extensionAuthor.empty() || extensionDescription.empty()) {
			warnings.push_back(filename + ": Couldn't read extension attributes (name, author, description).");
			continue;
		}

		std::string extensionUrl = extensionNode.attribute("url").as_string();
		extensionUrl.erase(std::remove(extensionUrl.begin(), extensionUrl.end(), '\''));

		std::string extensionAuthorLink = extensionNode.attribute("authorurl").as_string();
		extensionAuthorLink.erase(std::remove(extensionAuthorLink.begin(), extensionAuthorLink.end(), '\''));

		MaterialsExtension* materialExtension = newd MaterialsExtension(extensionName, extensionAuthor, extensionDescription);
		materialExtension->url = extensionUrl;
		materialExtension->author_url = extensionAuthorLink;

		if((attribute = extensionNode.attribute("client"))) {
			clientVersions.clear();
			const std::string& extensionClientString = attribute.as_string();

			size_t lastPosition = 0;
			size_t position = extensionClientString.find(';');
			while(position != std::string::npos) {
				clientVersions.push_back(extensionClientString.substr(lastPosition, position - lastPosition));
				lastPosition = position + 1;
				position = extensionClientString.find(';', lastPosition);
			}

			clientVersions.push_back(extensionClientString.substr(lastPosition));
			for(const std::string& version : clientVersions) {
				materialExtension->addVersion(version);
			}

			std::sort(materialExtension->version_list.begin(), materialExtension->version_list.end(), VersionComparisonPredicate);

			auto duplicate = std::unique(materialExtension->version_list.begin(), materialExtension->version_list.end());
			while(duplicate != materialExtension->version_list.end()) {
				materialExtension->version_list.erase(duplicate);
				duplicate = std::unique(materialExtension->version_list.begin(), materialExtension->version_list.end());
			}
		} else {
			warnings.push_back(filename + ": Extension is not available for any version.");
		}

		extensions.push_back(materialExtension);
		if(materialExtension->isForVersion(g_gui.GetCurrentVersionID())) {
			unserializeMaterials(filename, extensionNode, error, warnings);
		}
	} while(ext_dir.GetNext(&filename));

	return true;
}
예제 #22
0
파일: config.cpp 프로젝트: borzh/botrix
//----------------------------------------------------------------------------------------------------------------
void CConfiguration::LoadWeapons( good::ini_file::const_iterator it )
{
    good::string_buffer sbBuffer(szMainBuffer, iMainBufferSize, false);
    CWeapons::Clear();

    // Iterate throught key-values of weapons section.
    BLOG_D("Weapons:");
    for ( good::ini_section::const_iterator itemIt = it->begin(); itemIt != it->end(); ++itemIt )
    {
        sbBuffer = itemIt->value;
        good::escape(sbBuffer);

        StringVector aParams;
        good::split((good::string)sbBuffer, aParams, ',', true);
        good::vector<good::string> aAmmos[2];
        good::vector<int> aAmmosCount[2];

        CWeapon* pWeapon = new CWeapon();
        StringVector aCurrent;
        aCurrent.reserve(4);

        bool bError = false;
        int iSecondary = 0;
        for ( StringVector::iterator paramsIt = aParams.begin(); paramsIt != aParams.end(); ++paramsIt )
        {
            int iValue = -1;
            bool bProcessed = true;

            aCurrent.clear();
            good::split(*paramsIt, aCurrent);
            BASSERT( aCurrent.size() > 0, exit(1) );

            if ( aCurrent[0] == "class" )
            {
                if ( aCurrent.size() > 1 )
                {
                    for ( int i=1; i<aCurrent.size(); ++i )
                    {
                        TClass iClass = CTypeToString::ClassFromString(aCurrent[i]);
                        if ( iClass == -1 )
                        {
                            BLOG_E( "File \"%s\", section [%s]:", m_iniFile.name.c_str(), it->name.c_str() );
                            BLOG_E( "  Weapon %s, invalid class: %s.", itemIt->key.c_str(), aCurrent[1].c_str() );
                            bError = true;
                            break;
                        }
                        FLAG_SET(1 << iClass, pWeapon->iClass);
                    }
                    if ( bError )
                        break;
                }
                else
                {
                    BLOG_E( "File \"%s\", section [%s]:", m_iniFile.name.c_str(), it->name.c_str() );
                    BLOG_E( "  Weapon %s, class not specified.", itemIt->key.c_str() );
                    bError = true;
                    break;
                }
            }
            else if ( aCurrent.size() == 1 )
            {
                if ( aCurrent[0] == "secondary" )
                    iSecondary = CWeapon::SECONDARY;
                else
                {
                    TWeaponFlags iFlag = CTypeToString::WeaponFlagsFromString(aCurrent[0]);
                    if ( iFlag == -1 )
                        bProcessed = false;
                    else
                        FLAG_SET(iFlag, pWeapon->iFlags[iSecondary]);
                }
            }
            else if ( aCurrent.size() == 2 )
            {
                if ( aCurrent[0] == "type" )
                {
                    int iType = CTypeToString::WeaponTypeFromString(aCurrent[1]);
                    if ( iType == -1 )
                    {
                        BLOG_E( "File \"%s\", section [%s]:", m_iniFile.name.c_str(), it->name.c_str() );
                        BLOG_E( "  Weapon %s, invalid type: %s.", itemIt->key.c_str(), aCurrent[1].c_str() );
                        bError = true;
                        break;
                    }
                    pWeapon->iType = iType;

                    // Set weapon default parameters.
                    switch (iType)
                    {
                    case EWeaponMelee:
                    case EWeaponPhysics:
                        pWeapon->iAttackBullets[0] = pWeapon->iAttackBullets[1] = 0;
                        break;
                    case EWeaponRocket:
                    case EWeaponGrenade:
                    case EWeaponRemoteDetonation:
                        pWeapon->iClipSize[0] = 1;
                        break;
                    }
                }
                else if ( aCurrent[0] == "preference" )
                {
                    iValue = CTypeToString::PreferenceFromString(aCurrent[1]);
                    if ( iValue == -1 )
                        bProcessed = false;
                    else
                        pWeapon->iBotPreference = iValue;
                }
                else if ( aCurrent[0] == "team" )
                {
                    iValue = CMod::GetTeamIndex(aCurrent[1]);
                    if ( iValue == -1 )
                    {
                        BLOG_E( "File \"%s\", section [%s]:", m_iniFile.name.c_str(), it->name.c_str() );
                        BLOG_E( "  Weapon %s, invalid team: %s.", itemIt->key.c_str(), aCurrent[1].c_str() );
                        bError = true;
                        break;
                    }
                    pWeapon->iTeam = 1 << iValue;
                }
                else if ( aCurrent[0] == "aim" )
                {
                    TWeaponAim iAim = CTypeToString::WeaponAimFromString(aCurrent[1]);
                    if ( iAim == -1 )
                        bProcessed = false;
                    else
                        pWeapon->iAim[iSecondary] = iAim;
                }
                else
                {
                    sscanf(aCurrent[1].c_str(), "%d", &iValue);
                    if ( iValue < 0 )
                    {
                        BLOG_E( "File \"%s\", section [%s]:", m_iniFile.name.c_str(), it->name.c_str() );
                        BLOG_E( "   Weapon %s, invalid number: %s for parameter %s.", itemIt->key.c_str(), aCurrent[1].c_str(), aCurrent[0].c_str() );
                        bError = true;
                        break;
                    }

                    if ( aCurrent[0] == "clip" )
                        pWeapon->iClipSize[iSecondary] = iValue;

                    else if ( aCurrent[0] == "damage" )
                        pWeapon->fDamage[iSecondary] = iValue;

                    else if ( aCurrent[0] == "delay" )
                        pWeapon->fShotTime[iSecondary] = iValue / 1000.0f;

                    else if ( aCurrent[0] == "hold" )
                        pWeapon->fHoldTime[iSecondary] = iValue / 1000.0f;

                    else if ( aCurrent[0] == "reload_by" )
                        pWeapon->iReloadBy[iSecondary] = iValue;

                    else if ( aCurrent[0] == "reload" )
                        pWeapon->fReloadTime[iSecondary] = iValue / 1000.0f;

                    else if ( aCurrent[0] == "reload_start" )
                        pWeapon->fReloadStartTime[iSecondary] = iValue / 1000.0f;

                    else if ( aCurrent[0] == "holster" )
                        pWeapon->fHolsterTime = iValue / 1000.0f;

                    else if ( aCurrent[0] == "default_ammo" )
                        pWeapon->iDefaultAmmo[iSecondary] = iValue;

                    else if ( aCurrent[0] == "max_ammo" )
                        pWeapon->iMaxAmmo[iSecondary] = iValue;

                    else if ( aCurrent[0] == "bullets" )
                        pWeapon->iAttackBullets[iSecondary] = iValue;

                    else if ( aCurrent[0] == "default_ammo" )
                        pWeapon->iDefaultAmmo[iSecondary] = iValue;

                    else if ( aCurrent[0] == "zoom_distance" )
                        pWeapon->fMinDistanceSqr[1] = SQR(iValue);

                    else if ( aCurrent[0] == "zoom_time" )
                        pWeapon->fShotTime[1] = iValue / 1000.0f;

                    else
                        bProcessed = false;
                }
            }
            else if ( aCurrent.size() == 3 )
            {
                if ( aCurrent[0] == "ammo" )
                {
                    aAmmos[iSecondary].reserve(4);
                    int iValue = -1;
                    sscanf(aCurrent[2].c_str(), "%d", &iValue);
                    if ( iValue <= 0 ) // Ammo count can't be 0.
                    {
                        BLOG_E( "File \"%s\", section [%s]:", m_iniFile.name.c_str(), it->name.c_str() );
                        BLOG_E( "  Weapon %s, invalid parameter for '%s' ammo's count: %s.",
                                itemIt->key.c_str(), aCurrent[1].c_str(), aCurrent[2].c_str());
                        bError = true;
                        break;
                    }

                    good::string sAmmo(aCurrent[1], true);
                    aAmmos[iSecondary].push_back(sAmmo);
                    aAmmosCount[iSecondary].push_back(iValue);
                }
                else
                {
                    int iValue1 = -1, iValue2 = -1;
                    sscanf(aCurrent[1].c_str(), "%d", &iValue1);
                    sscanf(aCurrent[2].c_str(), "%d", &iValue2);
                    if ( (iValue1 < 0) || (iValue2 < 0) || (iValue1 >= CUtil::iMaxMapSize) || (iValue1 >= CUtil::iMaxMapSize) )
                        bProcessed = false;
                    else
                    {
                        if ( aCurrent[0] == "parabolic" )
                        {
                            pWeapon->iParabolicDistance0[iSecondary] = iValue1;
                            pWeapon->iParabolicDistance45[iSecondary] = iValue2;
                        }
                        else if ( aCurrent[0] == "range" )
                        {
                            pWeapon->fMinDistanceSqr[iSecondary] = SQR(iValue1);
                            if ( iValue2 == 0 )
                                pWeapon->fMaxDistanceSqr[iSecondary] = CUtil::iMaxMapSizeSqr;
                            else
                                pWeapon->fMaxDistanceSqr[iSecondary] = SQR(iValue2);
                        }
                        else
                            bProcessed = false;
                    }
                }
            }
            else
                bProcessed = false;

            if ( !bProcessed )
            {
                BLOG_W( "File \"%s\", section [%s]:", m_iniFile.name.c_str(), it->name.c_str() );
                BLOG_W( "  Weapon %s, unknown keyword %s or invalid parameters, skipping.",
                        itemIt->key.c_str(), aCurrent[0].c_str() );
            }
        }

        if ( bError )
            delete pWeapon;
        else
        {
            BLOG_D( "  %s", itemIt->key.c_str() );

            pWeapon->iId = CWeapons::Size();
            BLOG_D( "    id %d", pWeapon->iId );

            if ( pWeapon->iTeam )
            {
                BLOG_D( "    team %s", CTypeToString::TeamFlagsToString(pWeapon->iTeam).c_str() );
                //if ( FLAGS_SOME_SET(FDeathmatchTeamAllWeapons, CMod::iDeathmatchFlags) )
                pWeapon->iTeam |= 1 << CMod::iUnassignedTeam;
            }
            else
                pWeapon->iTeam = -1; // Mark to use by any flag.

            if ( CMod::aClassNames.size() )
                BLOG_D( "    class %s", CTypeToString::ClassFlagsToString(pWeapon->iClass).c_str() );
            else
                pWeapon->iClass = -1; // Mark to use by any flag.

            // If reload_by is not specified, assume reload refill the clip.
            for ( int i=0; i < 2; ++i )
                if ( pWeapon->iReloadBy[i] == 0 )
                    pWeapon->iReloadBy[i] = pWeapon->iClipSize[i];

            // Add weapon class.
            CItemClass cEntityClass;
            cEntityClass.sClassName.assign(itemIt->key, true);
            pWeapon->pWeaponClass = CItems::AddItemClassFor( EItemTypeWeapon, cEntityClass );

            // Add ammo classes.
            pWeapon->aAmmos[0].reserve(aAmmos[0].size());
            pWeapon->aAmmos[1].reserve(aAmmos[1].size());
            for ( int iSec=0; iSec < 2; ++iSec )
                for ( int i=0; i < aAmmos[iSec].size(); ++i )
                {
                    const good::string& sAmmo = aAmmos[iSec][i];
                    const CItemClass* pAmmoClass = CItems::GetItemClass( EItemTypeAmmo, sAmmo );
                    if ( !pAmmoClass )
                    {
                        CItemClass cAmmoClass;
                        cAmmoClass.sClassName = sAmmo;
                        pAmmoClass = CItems::AddItemClassFor( EItemTypeAmmo, cAmmoClass );
                    }
                    pWeapon->aAmmos[iSec].push_back( pAmmoClass );
                    pWeapon->aAmmosCount[iSec].push_back( aAmmosCount[iSec][i] );
                    BLOG_D( "    ammo %s (%u bullets)",
                            pWeapon->aAmmos[iSec][i]->sClassName.c_str(), pWeapon->aAmmosCount[iSec][i] );
                }

            CWeaponWithAmmo cWeapon(pWeapon);
            CWeapons::Add(cWeapon);
        }
    }
}
예제 #23
0
void LinkInfo::initialiseLinks () 
{
	GenIFStream fromFile ( MsparamsDir::instance ().getParamPath ( "links.txt" ) );
	string line;
	bool menuItem = true;
	string l1AA;
	string l2AA;
	string bf;
	StringVector u;

	ScoreType maxPScore = 100.0 * SCORE_TYPE_MULTIPLIER;	// Set to a value so all p ions are counted by default;
	string pCIDImmFormula;
	ScoreType pCIDScore = DEFAULT_MISS_SCORE;
	ScoreType pCIDXLScore = DEFAULT_MISS_SCORE;
	ScoreType pCIDImmScore = DEFAULT_MISS_SCORE;
	ScoreType pCIDH2OScore = DEFAULT_MISS_SCORE;
	ScoreType pCIDNH3Score = DEFAULT_MISS_SCORE;
	ScoreType pCID2H2OScore = DEFAULT_MISS_SCORE;
	ScoreType pCIDXLH2OScore = DEFAULT_MISS_SCORE;
	ScoreType pCIDXLNH3Score = DEFAULT_MISS_SCORE;
	ScoreType pCIDImmH2OScore = DEFAULT_MISS_SCORE;
	ScoreType pCIDImmNH3Score = DEFAULT_MISS_SCORE;
	ScoreType pETDScore = DEFAULT_MISS_SCORE;
	ScoreType pETDXLScore = DEFAULT_MISS_SCORE;

	while ( getline ( fromFile, line ) ) {
		if ( line.length () != 0 && line [0] != '#' ) {
			if ( menuItem ) {
				nameList.push_back ( line );
				menuItem = false;
			}
			if ( line != ">" ) {
				istringstream ist ( line );
				string name;
				ist >> name;
				if ( !name.empty () ) {
					string value = gen_strtrim ( line.substr ( name.length () ) );
					if ( name == "link_aa_1" )		l1AA = value;
					if ( name == "link_aa_2" )		l2AA = value;
					if ( name == "bridge_formula" )	bf = value;
					if ( name == "usermod" )		u.push_back ( value );

					if ( name == "max_p_score" )			maxPScore		= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_imm_formula" )		pCIDImmFormula	= value;
					if ( name == "p_cid_score" )			pCIDScore		= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_xl_score" )				pCIDXLScore		= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_imm_score" )		pCIDImmScore	= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_h2o_score" )		pCIDH2OScore	= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_nh3_score" )		pCIDNH3Score	= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_2h2o_score" )		pCID2H2OScore	= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_xl_h2o_score" )			pCIDXLH2OScore	= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_xl_nh3_score" )			pCIDXLNH3Score	= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_imm_h2o_score" )		pCIDImmH2OScore	= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_cid_imm_nh3_score" )		pCIDImmNH3Score	= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;

					if ( name == "p_etd_score" )			pETDScore		= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
					if ( name == "p_etd_xl_score" )				pETDXLScore		= atof ( value.c_str () ) * SCORE_TYPE_MULTIPLIER;
				}
			}
			else {
				if ( !l1AA.empty () )	linkAA1List.push_back ( l1AA );
				else ErrorHandler::genError ()->error ( "Missing parameter link_aa_1 in parameter file links.txt.\n" );
				if ( !l2AA.empty () )	linkAA2List.push_back ( l2AA );
				else ErrorHandler::genError ()->error ( "Missing parameter link_aa_2 in parameter file links.txt.\n" );
				if ( !bf.empty () )		bridgeFormulaList.push_back ( bf );
				else ErrorHandler::genError ()->error ( "Missing parameter bridge_formula in parameter file links.txt..\n" );
				usermodList.push_back ( u );

				maxPScoreList.push_back			( maxPScore );
				pCIDImmFormulaList.push_back	( pCIDImmFormula );
				pCIDScoreList.push_back			( pCIDScore );
				pCIDXLScoreList.push_back		( pCIDXLScore );
				pCIDImmScoreList.push_back		( pCIDImmScore );
				pCIDH2OScoreList.push_back		( pCIDH2OScore );
				pCIDNH3ScoreList.push_back		( pCIDNH3Score );
				pCID2H2OScoreList.push_back		( pCID2H2OScore );
				pCIDXLH2OScoreList.push_back	( pCIDXLH2OScore );
				pCIDXLNH3ScoreList.push_back	( pCIDXLNH3Score );
				pCIDImmH2OScoreList.push_back	( pCIDImmH2OScore );
				pCIDImmNH3ScoreList.push_back	( pCIDImmNH3Score );
				pETDScoreList.push_back			( pETDScore );
				pETDXLScoreList.push_back		( pETDXLScore );

				l1AA = "";
				l2AA = "";
				bf = "";
				u.clear ();

				maxPScore		= 100.0 * SCORE_TYPE_MULTIPLIER;	// Set to a value so all p ions are counted by default
				pCIDImmFormula	= "";
				pCIDScore		= DEFAULT_MISS_SCORE;
				pCIDXLScore		= DEFAULT_MISS_SCORE;
				pCIDImmScore	= DEFAULT_MISS_SCORE;
				pCIDH2OScore	= DEFAULT_MISS_SCORE;
				pCIDNH3Score	= DEFAULT_MISS_SCORE;
				pCID2H2OScore	= DEFAULT_MISS_SCORE;
				pCIDXLH2OScore	= DEFAULT_MISS_SCORE;
				pCIDXLNH3Score	= DEFAULT_MISS_SCORE;
				pCIDImmH2OScore	= DEFAULT_MISS_SCORE;
				pCIDImmNH3Score	= DEFAULT_MISS_SCORE;
				pETDScore		= DEFAULT_MISS_SCORE;
				pETDXLScore		= DEFAULT_MISS_SCORE;

				menuItem = true;
			}
		}
void VideoRegionsConfigDialog::apply()
{
  // FIXME: Bad code

  
  AutoLock al(m_config);

  //
  // Clear old video classes names container
  //

  StringVector *videoClasses = m_config->getVideoClassNames();
  videoClasses->clear();
  std::vector<Rect> *videoRects = m_config->getVideoRects();
  videoRects->clear();

  //
  // Split text from text area to string array
  //
  
  StringStorage classNames;
  m_videoClasses.getText(&classNames);
  size_t count = 0;
  TCHAR delimiters[] = _T(" \n\r\t,;");

  classNames.split(delimiters, NULL, &count);
  if (count != 0) {
    std::vector<StringStorage> chunks(count);
    classNames.split(delimiters, &chunks.front(), &count);

    for (size_t i = 0; i < count; i++) {
      if (!chunks[i].isEmpty()) {
          videoClasses->push_back(chunks[i].getString());
      }
    }
  }

  StringStorage videoRectsStringStorage;
  m_videoRects.getText(&videoRectsStringStorage);
  count = 0;

  videoRectsStringStorage.split(delimiters, NULL, &count);
  if (count != 0) {
    std::vector<StringStorage> chunks(count);
    videoRectsStringStorage.split(delimiters, &chunks.front(), &count);

    for (size_t i = 0; i < count; i++) {
      if (!chunks[i].isEmpty()) {
        try {
          videoRects->push_back(RectSerializer::toRect(&chunks[i]));
        } catch (...) {
          // Ignore wrong formatted strings
        }
      }
    }
  }

  //
  // TODO: Create parseUInt method
  //

  StringStorage vriss;

  m_videoRecognitionInterval.getText(&vriss);

  int interval;
  StringParser::parseInt(vriss.getString(), &interval);
  m_config->setVideoRecognitionInterval((unsigned int)interval);
}
예제 #25
0
void
StringTokenizer::tokenize( const std::string& input, StringVector& output ) const
{
    output.clear();

    std::stringstream buf;
    bool quoted = false;
    for( std::string::const_iterator i = input.begin(); i != input.end(); ++i )
    {
        char c = *i;    

        TokenMap::const_iterator q = _quotes.find( c );

        if ( quoted )
        {
            if ( q != _quotes.end() )
            {
                quoted = false;
                if ( q->second )
                    buf << c;
            }
            else
            {
                buf << c;
            }
        }
        else
        {
            if ( q != _quotes.end() )
            {
                quoted = true;
                if ( q->second )
                    buf << c;
            }
            else
            {
                TokenMap::const_iterator d = _delims.find( c );
                if ( d == _delims.end() )
                {
                    buf << c;
                }
                else
                {
                    std::string token = _trimTokens ? trim(buf.str()) : buf.str();

                    if ( _allowEmpties || !token.empty() )
                        output.push_back( token );

                    if ( d->second == true )
                    {
                        output.push_back( std::string(1, c) );
                    }

                    buf.str("");
                }
            }
        }       
    }

    std::string last = _trimTokens ? trim(buf.str()) : buf.str();
    if ( !last.empty() )
        output.push_back( last );
}
ML_START_NAMESPACE


//***********************************************************************************


void SavePRC::PreProcessMeshData(WEMPtr saveWEM, 
							                   PRCMeshInfoVector &meshInfoVector,
                                 ModelBoundingBoxStruct& boundingBox)
{
  if (!_inWEM) 
  { 
    return; 
  }

  MLuint32 meshNumber = 0;

  bool simpleMode = _simpleModeMeshFld->getBoolValue();

  StringVector meshSpecificationsVector;

  if (simpleMode)
  {
    //meshSpecificationsVector.push_back("<U3DMesh>");
  }
  else
  {
    meshSpecificationsVector = getObjectSpecificationsStringFromUI(_meshSpecificationFld, "<Mesh>");
  }

  // Scan all WEM patches, triangulate them if necessary and collect base info.
  WEMPatch*           wemPatch = NULL;
  WEMTrianglePatch*   addedTrianglePatch = NULL;

  _statusFld->setStringValue("Analyzing mesh specification and input WEM.");

  const MLuint32 numberOfWEMPatches = _inWEM->getNumWEMPatches();

  for (MLuint32 i = 0; i < numberOfWEMPatches; i++)
  {
    PRCMeshInfoStruct   thisWEMMeshInfo;

    wemPatch = _inWEM->getWEMPatchAt(i); 
    addedTrianglePatch = NULL;
    const unsigned int newId = saveWEM->getCurrentWEMPatchId();

    if (wemPatch->getNumFaces() > 0)
    {

      if (wemPatch->getPatchType() != WEM_PATCH_TRIANGLES)
      {
        WEMTrianglePatch* triangulatedPatch = NULL;

        ML_CHECK_NEW(triangulatedPatch,WEMTrianglePatch());
        wemPatch->triangulate(triangulatedPatch, WEM_TRIANGULATION_STRIP);
        addedTrianglePatch = saveWEM->addWEMPatchCopy(triangulatedPatch);
        addedTrianglePatch->computeBoundingBox();
        ML_DELETE(triangulatedPatch);
      }
      else
      {
        addedTrianglePatch = saveWEM->addWEMPatchCopy(reinterpret_cast<WEMTrianglePatch*>(wemPatch));
      }

      if (addedTrianglePatch != NULL) 
      {
        addedTrianglePatch->setId(newId);

        // Adjust properties of main WEM bounding box
        WEMBoundingBox* thisWEMPatchBoundingBox = addedTrianglePatch->getBoundingBox();
        ModelBoundingBoxStruct newboundingBox;
        newboundingBox.start = thisWEMPatchBoundingBox->getMin();
        newboundingBox.end   = thisWEMPatchBoundingBox->getMax();
        UpdateBoundingBox(boundingBox, newboundingBox);

	      std::string wemDescription = addedTrianglePatch->getDescription();
        std::string wemLabel = addedTrianglePatch->getLabel();

        SpecificationParametersStruct thisSpecificationParameters;

        // Create an artificial meshSpecificationVector if only WEM label & description shall be used 
        if (simpleMode)
        {
          meshSpecificationsVector.clear();

          // Parse WEM label & description...
          std::string u3dModelName       = getSpecificParameterFromWEMDescription(wemDescription, "ModelName");
          std::string u3dGroupName       = getSpecificParameterFromWEMDescription(wemDescription, "GroupName");
          std::string u3dGroupPath       = "";
          if ("" != u3dModelName)
          {
            u3dGroupPath = "/" + u3dModelName + "/";
          }
          if ("" != u3dGroupName)
          {
            if ("" == u3dGroupPath)
            {
              u3dGroupPath += "/";
            }
            u3dGroupPath += u3dGroupName + "/";
          }

          std::string displayName = wemLabel;
          if (displayName == "") {
            displayName = "Mesh " + intToString(i+1);
          }

          // ...and write data into meshSpecification string
          std::string meshSpecificationsString = "<U3DMesh>";
          meshSpecificationsString += "<WEMLabel>" + wemLabel + "</WEMLabel>";
          meshSpecificationsString += "<ObjectName>" + displayName + "</ObjectName>";
          meshSpecificationsString += "<GroupPath>" + u3dGroupPath + "</GroupPath>";
          meshSpecificationsString += "<Color>" + getSpecificParameterFromWEMDescription(wemDescription, "Color") + "</Color>";
          meshSpecificationsString += "<SpecularColor>" + getSpecificParameterFromWEMDescription(wemDescription, "SpecularColor") + "</SpecularColor>";
          meshSpecificationsString += "<ModelVisibility>3</ModelVisibility>";

          // Add meshSpecification string to meshSpecificationVector
          meshSpecificationsVector.push_back(meshSpecificationsString);
        }

        for (int thisSpecificationIndex = 0; thisSpecificationIndex < meshSpecificationsVector.size(); thisSpecificationIndex++)
        {
          thisSpecificationParameters = getAllSpecificationParametersFromString(meshSpecificationsVector[thisSpecificationIndex]);
          if (thisSpecificationParameters.WEMLabel == wemLabel)
          {
            PRCObjectInfoStruct thisPRCObjectInfo = CreateNewPRCObjectInfo(i,PRCOBJECTTYPE_MESH, thisSpecificationParameters.ObjectName, defaultValues);
            thisPRCObjectInfo.GroupPath        = thisSpecificationParameters.GroupPath;
            thisPRCObjectInfo.ParentTreeNodeID = -1;
            thisPRCObjectInfo.RGBAColor        = getColorVec4(thisSpecificationParameters.Color, Vector4(0));  // If alpha = 0 -> Adobe doesn't render;
            _prcObjectInfoVector.push_back(thisPRCObjectInfo);



            // Collect mesh info
            thisWEMMeshInfo.DiffuseColorCount    = 0;    // This is not really needed in this version
            thisWEMMeshInfo.SpecularColorCount   = 0;    // This is not really needed in this version
            thisWEMMeshInfo.TextureCoordCount    = 0;    // This is not really needed in this version
            thisWEMMeshInfo.DefaultAmbientColor  = defaultValues.defaultMaterialAmbientColor;
            thisWEMMeshInfo.DefaultSpecularColor = defaultValues.defaultMaterialSpecularColor;
            thisWEMMeshInfo.DefaultDiffuseColor  = defaultValues.defaultMaterialDiffuseColorWithTransparency;
            thisWEMMeshInfo.DefaultEmissiveColor = defaultValues.defaultMaterialEmissiveColor;            
            thisWEMMeshInfo.FaceCount = addedTrianglePatch->getNumFaces();
            thisWEMMeshInfo.NormalCount = addedTrianglePatch->getNumFaces();
            thisWEMMeshInfo.VertexCount = addedTrianglePatch->getNumNodes();            
            thisWEMMeshInfo.PatchID = addedTrianglePatch->getId();
  //          thisWEMMeshInfo.MeshAttributes = U3D_MESH_ATTRIBUTES_DEFAULT;
  //          thisWEMMeshInfo.MeshAttributes |= ( (thisWEMMeshInfo.NormalCount == 0) ? U3D_MESH_ATTRIBUTES_EXCLUDENORMALS : 0 );
  //          thisWEMMeshInfo.ShadingAttributes = U3D_SHADINGATTRIBUTES_NONE;  
  //          thisWEMMeshInfo.ShadingAttributes |= ( (thisWEMMeshInfo.DiffuseColorCount > 0) ? U3D_SHADINGATTRIBUTES_DIFFUSECOLORS : 0 );   // Should not happen in this version
  //          thisWEMMeshInfo.ShadingAttributes |= ( (thisWEMMeshInfo.SpecularColorCount > 0) ? U3D_SHADINGATTRIBUTES_SPECULARCOLORS : 0 ); // Should not happen in this version
  //          thisWEMMeshInfo.ResourceName = thisPRCObjectInfo.ResourceName;
            thisWEMMeshInfo.MeshNumber = meshNumber++;

	          meshInfoVector.push_back(thisWEMMeshInfo);           
          }
        }

      }  // if (addedTrianglePatch != NULL)

    }  // if (wemPatch->getNumFaces() > 0)

    wemPatch = NULL;
  }

}
int CVerilogCounter::CountComplexity(filemap* fmap, results* result)
{
	if (classtype == UNKNOWN || classtype == DATAFILE)
		return 0;
	filemap::iterator fit;
	filemap fitBak;
	filemap::iterator fitForw, fitBack;//used to check prior an later lines for semicolons
	//unsigned int cnt;
	//string line, line2;
	string exclude = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_$><=:";
	tokLocVect conditionalVector;
	tokLocVect::reverse_iterator r_tlvIter;
	//StringVector::iterator strIter = this->cmplx_cond_list.begin(); warning fix
	string buf;			// have a buffer string
	stringstream ss;	// insert the string into a stream
	tokenLocation tl;
	int count;
	bool whenCont;
    
    	size_t idx;
	unsigned int cnt, ret, cyclomatic_cnt = 0, ignore_cyclomatic_cnt = 0, main_cyclomatic_cnt = 0, /*function_count = 0, */cyclomatic_logic_cnt = 0, main_cyclomatic_logic_cnt = 1, cyclomatic_case_cnt = 0, main_cyclomatic_case_cnt = 1; // warning fix
	string line, lastline, file_ext, function_name = "";
    	StringVector function_stack;
	stack<unsigned int> cyclomatic_stack;
	stack<unsigned int> cyclomatic_logic_stack;
	stack<unsigned int> cyclomatic_case_stack;
	bool process_cyclomatic_complexity = false;
    	bool first_line_in_main = true;

    	StringVector switch_case_key_list;
    	StringVector switch_case_stack;
    	switch_case_key_list.push_back(":");    
    
	// check whether to process cyclomatic complexity
	if (cmplx_cyclomatic_list.size() > 0)
	{
		process_cyclomatic_complexity = true;
		if (skip_cmplx_cyclomatic_file_extension_list.size() > 0)
		{
			idx = result->file_name.find_last_of(".");
			if (idx != string::npos)
			{
				file_ext = result->file_name.substr(idx);
				file_ext = CUtil::ToLower(file_ext);
				if (find(skip_cmplx_cyclomatic_file_extension_list.begin(), skip_cmplx_cyclomatic_file_extension_list.end(), file_ext) != skip_cmplx_cyclomatic_file_extension_list.end())
					process_cyclomatic_complexity = false;
			}
		}
	}
    
	for (fit = fmap->begin(); fit != fmap->end(); fit++)
	{
		line = fit->line;
        
		if (CUtil::CheckBlank(line))
			continue;
        
		line = " " + line;
        
		// mathematical functions
		cnt = 0;
		CUtil::CountTally(line, math_func_list, cnt, 1, exclude, "", "", &result->math_func_count, casesensitive);
		result->cmplx_math_lines += cnt;
        
		// trigonometric functions
		cnt = 0;
		CUtil::CountTally(line, trig_func_list, cnt, 1, exclude, "", "", &result->trig_func_count, casesensitive);
		result->cmplx_trig_lines += cnt;
        
		// logarithmic functions
		cnt = 0;
		CUtil::CountTally(line, log_func_list, cnt, 1, exclude, "", "", &result->log_func_count, casesensitive);
		result->cmplx_logarithm_lines += cnt;
        
		// calculations
		cnt = 0;
		CUtil::CountTally(line, cmplx_calc_list, cnt, 1, exclude, "", "", &result->cmplx_calc_count, casesensitive);
		result->cmplx_calc_lines += cnt;
        
		// conditionals
		cnt = 0;
		CUtil::CountTally(line, cmplx_cond_list, cnt, 1, exclude, "", "", &result->cmplx_cond_count, casesensitive);
		result->cmplx_cond_lines += cnt;
        
		// logical operators
		cnt = 0;
		StringVector tmpList = cmplx_logic_list;//making a temporary list with the '<=' operator removed from the list; counting it on another pass;
		tmpList.pop_back();
		CUtil::CountTally(line, tmpList, cnt, 1, exclude, "", "", &result->cmplx_logic_count, casesensitive);
		result->cmplx_logic_lines += cnt;
        
		// preprocessor directives
		cnt = 0;
		CUtil::CountTally(line, cmplx_preproc_list, cnt, 1, exclude, "", "", &result->cmplx_preproc_count, casesensitive);
		result->cmplx_preproc_lines += cnt;
        
		// assignments
		cnt = 0;
		tmpList.clear();
		tmpList = cmplx_assign_list;//making a temporary list with the '<=' operator removed from the list; counting it on another pass;
		tmpList.pop_back();
		CUtil::CountTally(line, tmpList, cnt, 1, exclude, "", "", &result->cmplx_assign_count, casesensitive);
		result->cmplx_assign_lines += cnt;
     
	/* No pointer for Verilog
		// pointers
		cnt = 0;
		// Pointers are embedded syntax so there is NO exclude string or include strings
		CUtil::CountTally(line, cmplx_pointer_list, cnt, 1, "", "", "", &result->cmplx_pointer_count, casesensitive);
		result->cmplx_pointer_lines += cnt;
	*/
        
        	// cyclomatic complexity
		if (process_cyclomatic_complexity)
		{
			// search for cyclomatic complexity keywords
			unsigned int temp = 0;
			CUtil::CountTally(line, cmplx_cyclomatic_list, temp, 1, exclude, "", "", 0, casesensitive);
            		cyclomatic_cnt += temp;

			// search for keywords to exclude
			if (ignore_cmplx_cyclomatic_list.size() > 0)
				CUtil::CountTally(line, ignore_cmplx_cyclomatic_list, ignore_cyclomatic_cnt, 1, exclude, "", "", 0, casesensitive);

			// search for cyclomatic complexity case keywords
			if (cmplx_cyclomatic_case_list.size() > 0)
				CUtil::CountTally(line, cmplx_cyclomatic_case_list, cyclomatic_case_cnt, 1, exclude, "", "", 0, casesensitive);
			cyclomatic_case_cnt += temp;

			//search for keyword "case"
            		size_t idx_case = CUtil::FindKeyword(line, "case");
            		if (idx_case != string::npos) {
                		switch_case_stack.push_back("case");
            		}
			//search for keyword "case"
            		idx_case = CUtil::FindKeyword(line, "casez");
            		if (idx_case != string::npos) {
                		switch_case_stack.push_back("case");
            		}
			//search for keyword "case"
            		idx_case = CUtil::FindKeyword(line, "casex");
            		if (idx_case != string::npos) {
                		switch_case_stack.push_back("case");
            		}

			//only if switch_case_stack is not empty, we will search keyword ":" and "[" and "?"
            		if(!switch_case_stack.empty()){
                		size_t idx = CUtil::FindKeyword(line, ":");
                		size_t idx_1 = CUtil::FindKeyword(line, "[");
                		size_t idx_2 = CUtil::FindKeyword(line, "?");
                		size_t idx_3 = CUtil::FindKeyword(line, "default");
                		if ((idx != string::npos) && ((idx_1 == string::npos) || (idx < idx_1)) && ((idx_2 == string::npos) || (idx < idx_2)) && (idx_3 == string::npos)) {
                        		cyclomatic_cnt++;
                		}
                
                		//search for keyword "endcase"
                		idx = CUtil::FindKeyword(line, "endcase");
                		if (idx != string::npos) {
                    			switch_case_stack.pop_back();
                		}
            		}

			// search for cyclomatic complexity logical keywords
			if (cmplx_cyclomatic_logic_list.size() > 0)
				CUtil::CountTally(line, cmplx_cyclomatic_logic_list, cyclomatic_logic_cnt, 1, exclude, "", "", 0, casesensitive);

            
			// parse function name if found
			ret = (unsigned)ParseFunctionName(line, lastline, function_stack, function_name);
			if (ret != 1 && !cyclomatic_stack.empty() && cyclomatic_stack.size() == function_stack.size())
			{
				// remove count stack entry for non-function names
				cyclomatic_cnt += cyclomatic_stack.top();
				ignore_cyclomatic_cnt = 0;
				cyclomatic_stack.pop();
			}
			if (ret != 1 && !cyclomatic_logic_stack.empty() && cyclomatic_logic_stack.size() == function_stack.size()-1)
			{
				// remove count stack entry for non-function names
				cyclomatic_logic_cnt += cyclomatic_logic_stack.top();
				cyclomatic_logic_stack.pop();
			}
			if (ret != 1 && !cyclomatic_case_stack.empty() && cyclomatic_case_stack.size() == function_stack.size()-1)
			{
				// remove count stack entry for non-function names
				cyclomatic_case_cnt += cyclomatic_case_stack.top();
				cyclomatic_case_stack.pop();
			}

			if (ret == 1)
			{
				// capture count at end of function
				lineElement element(cyclomatic_cnt - ignore_cyclomatic_cnt + 1, function_name);
				result->cmplx_cycfunct_count.push_back(element);

				lineElement n_element(cyclomatic_cnt - ignore_cyclomatic_cnt + cyclomatic_logic_cnt + 1, function_name);
				result->cmplx_cycfunct_CC2_count.push_back(n_element);

				lineElement c_element(cyclomatic_case_cnt - ignore_cyclomatic_cnt + 1, function_name);
				result->cmplx_cycfunct_CC3_count.push_back(c_element);
                
				if (!function_stack.empty())
				{
					// grab previous function from stack to continue
					if (!cyclomatic_stack.empty())
					{
						cyclomatic_cnt = cyclomatic_stack.top();
						cyclomatic_stack.pop();
					}
					if (!cyclomatic_logic_stack.empty())
					{
						cyclomatic_logic_cnt = cyclomatic_logic_stack.top();
						cyclomatic_logic_stack.pop();
					}
					if (!cyclomatic_case_stack.empty())
					{
						cyclomatic_case_cnt = cyclomatic_case_stack.top();
						cyclomatic_case_stack.pop();
					}
				}
				else {
					cyclomatic_cnt = 0;
					cyclomatic_logic_cnt = 0;
					cyclomatic_case_cnt = 0;
				}
				function_name = "";
				ignore_cyclomatic_cnt = 0;
			}
			else if (ret == 2)
			{
                		if (first_line_in_main) 
				{
                    			main_cyclomatic_cnt = 1;
                    			first_line_in_main = false;
                		}
				if (main_cyclomatic_cnt < 1)
					main_cyclomatic_cnt = 1;	// add 1 for main function here in case no other decision points are found in main
				// some code doesn't belong to any function
				main_cyclomatic_cnt += cyclomatic_cnt - ignore_cyclomatic_cnt;
				main_cyclomatic_logic_cnt += cyclomatic_cnt - ignore_cyclomatic_cnt + cyclomatic_logic_cnt;
				main_cyclomatic_case_cnt += cyclomatic_case_cnt - ignore_cyclomatic_cnt;
				cyclomatic_cnt = ignore_cyclomatic_cnt = cyclomatic_logic_cnt = cyclomatic_case_cnt = 0;
			}
			else { 
				if (!function_stack.empty() && (function_stack.size() > cyclomatic_stack.size() + 1 || (cyclomatic_stack.empty() && function_stack.size() > 1)))
				{
					// capture previous complexity count from open function
					cyclomatic_stack.push(cyclomatic_cnt - ignore_cyclomatic_cnt);
					cyclomatic_cnt = ignore_cyclomatic_cnt = 0;
				}
				if (!function_stack.empty() && (function_stack.size() > cyclomatic_logic_stack.size() + 1 || (cyclomatic_logic_stack.empty() && function_stack.size() > 1)))
				{
					// capture previous complexity count from open function
					cyclomatic_logic_stack.push(cyclomatic_logic_cnt);
					cyclomatic_logic_cnt = 0;
				}
				if (!function_stack.empty() && (function_stack.size() > cyclomatic_case_stack.size() + 1 || (cyclomatic_case_stack.empty() && function_stack.size() > 1)))
				{
					// capture previous complexity count from open function
					cyclomatic_case_stack.push(cyclomatic_case_cnt);
					cyclomatic_case_cnt = 0;
				}
			}
		}
        
	}
    
	// do a single pass to mark and replace logical operator lessThan or equal "<="
	// these appear only in conditional statements
	// the remaining are signal assignment operators
	for (fit = fmap->begin(); fit != fmap->end(); fit++)
	{
		line = fit->line;
		line = CUtil::ToLower(line);
		
		if (CUtil::CheckBlank(line))
			continue;
		ss.clear();
		ss.str("");
		ss << line;
		count = -1;
		while (ss >> buf)
		{
			++count;
			if (!buf.compare("if"))
			{
				tl.lineNumber = fit->lineNumber;
				tl.position = count;
				tl.token = buf;
				buf.clear();
				conditionalVector.push_back(tl);
				continue;
			}
			// No wait in Verilog
			// No until"))
			// No assert"))
			if (!buf.compare("while"))
			{
				tl.lineNumber = fit->lineNumber;
				tl.position = count;
				tl.token = buf;
				buf.clear();
				conditionalVector.push_back(tl);
				continue;
			}
			// No loop"))
			// No next"))
			// No when"))
			// No exit"))
			if (!buf.compare("return"))
			{
				tl.lineNumber = fit->lineNumber;
				tl.position = count;
				tl.token = buf;
				buf.clear();
				conditionalVector.push_back(tl);
				continue;
			}
			if (!buf.compare("case"))
			{
				tl.lineNumber = fit->lineNumber;
				tl.position = count;
				tl.token = buf;
				buf.clear();
				conditionalVector.push_back(tl);
				continue;
			}
			if (!buf.compare("casex"))
			{
				tl.lineNumber = fit->lineNumber;
				tl.position = count;
				tl.token = buf;
				buf.clear();
				conditionalVector.push_back(tl);
				continue;
			}
			if (!buf.compare("casez"))
			{
				tl.lineNumber = fit->lineNumber;
				tl.position = count;
				tl.token = buf;
				buf.clear();
				conditionalVector.push_back(tl);
				continue;
			}
			if (buf.find_last_of(";") != string::npos)
			{
				tl.lineNumber = fit->lineNumber;
				tl.position = count;
				tl.token = ";";
				buf.clear();
				conditionalVector.push_back(tl);
				continue;
			}
			if (buf.find("<=") != string::npos)
			{
				whenCont = false;
				// iterate up the vector an look for the first conditional statement
				r_tlvIter = conditionalVector.rbegin();
				while (r_tlvIter != conditionalVector.rend())
				{
					if (!r_tlvIter->token.compare(";"))
					{
						result->cmplx_assign_count.back()++;
						result->cmplx_assign_lines++;
						tl.token = "assign";
						break;
					}
					else
					{
						if ((!r_tlvIter->token.compare("if") || !r_tlvIter->token.compare("elsif") || !r_tlvIter->token.compare("assert") ||
                             !r_tlvIter->token.compare("while") || !r_tlvIter->token.compare("return") || !r_tlvIter->token.compare("until") ) && !whenCont)
						{
                            result->cmplx_logic_count.back()++;
                            result->cmplx_logic_lines++;
                            tl.token = "lte";
                            break;
						}
						if (!r_tlvIter->token.compare("when"))
						{
							whenCont = true;
							r_tlvIter++;
							continue;
						}
						if (!r_tlvIter->token.compare("case") || !r_tlvIter->token.compare("next") || !r_tlvIter->token.compare("exit"))
						{
							result->cmplx_assign_count.back()++;
							result->cmplx_assign_lines++;
							tl.token = "assign";
							whenCont = false;
							break;
						}
						result->cmplx_assign_count.back()++;
						result->cmplx_assign_lines++;
						tl.token = "assign";
						break;
					}
					//  r_tlvIter++;   MS VC++ warning C4702 unreachable code  TODO:  Review ! ! !
				}
				tl.lineNumber = fit->lineNumber;
				tl.position = count;
				buf.clear();
				conditionalVector.push_back(tl);
				continue;
			}
		}
        
	}
    	// done with a file, if has "main" code add it
	if (main_cyclomatic_cnt > 0)
	{
		lineElement element(main_cyclomatic_cnt, "main");
		lineElement n_element(main_cyclomatic_logic_cnt, "main");
		lineElement c_element(main_cyclomatic_case_cnt, "main");
		result->cmplx_cycfunct_count.push_back(element);
		result->cmplx_cycfunct_CC2_count.push_back(n_element);
		result->cmplx_cycfunct_CC3_count.push_back(c_element);
	}
	return 1;
}
예제 #28
0
// порождает по числительному генитивный вариант.
// например, два=>двух
// это генитивный вариант используетс¤ в слвоах типа "двухламповый"
bool BuildGenitFormOfCardinal(const CLemmatizer* piRusLemmatizer, const CRusGramTab* Agramtab) 
{
	GenitFormsOfCardinal.clear();
	for(int i = 0 ; i < NumeralToNumberCount; i++ )
	{
		if (NumeralToNumber[i].m_Number == 0)
		{
			GenitFormsOfCardinal.push_back("Ќ”Ћ№");
			continue;
		};
		if (NumeralToNumber[i].m_Number == 1)
		{
			GenitFormsOfCardinal.push_back("ќƒЌќ");
			continue;
		};
		if (NumeralToNumber[i].m_Number == 100)
		{
			GenitFormsOfCardinal.push_back("—“ќ");
			continue;
		};
		if (NumeralToNumber[i].m_Number == 1000)
		{
			GenitFormsOfCardinal.push_back("“џ—я„≈");
			continue;
		};
		if (NumeralToNumber[i].m_Number == 1000000)
		{
			GenitFormsOfCardinal.push_back("ћ»ЋЋ»ќЌќ");
			continue;
		};
		if (NumeralToNumber[i].m_Number == 1000000000)
		{
			GenitFormsOfCardinal.push_back("ћ»ЋЋ»ј–ƒЌќ");
			continue;
		};
		if (NumeralToNumber[i].m_Number == 1000000000000.0)
		{
			GenitFormsOfCardinal.push_back("“–»ЋЋ»ќЌќ");
			continue;
		};
		if (NumeralToNumber[i].m_Number == 1000000000000000.0)
		{
			GenitFormsOfCardinal.push_back(" ¬јƒ–»ЋЋ»ќЌќ");
			continue;
		};
		vector<CFormInfo> ParadigmCollection;
		string WordForm = NumeralToNumber[i].m_Cardinal;
		piRusLemmatizer->CreateParadigmCollection(true, WordForm, false, false, ParadigmCollection);
		// ищем числительное
		long k=0;
		for (; k < ParadigmCollection.size(); k++)
		{
			string AnCode = ParadigmCollection[k].GetAncode(0);
			BYTE POS = Agramtab->GetPartOfSpeech(AnCode.c_str());
            if (NumeralToNumber[i].m_bNoun)
            {
                if (POS == NOUN)
                    break;
            }
            else
			    if (POS == NUMERAL)
				    break;
		};
		assert (k < ParadigmCollection.size());
		const CFormInfo& P = ParadigmCollection[k];
		// ищем родительный падеж
		for (k=0; k < P.GetCount(); k++)
		{
			string AnCode = P.GetAncode(k);
			QWORD Grammems;
			if (!Agramtab->GetGrammems(AnCode.c_str(), Grammems))
				throw CExpc ("Bad ancode in  BuildGenitFormOfCardinal");
			if ( (Grammems & _QM(rGenitiv)) > 0 )
				break;
		};
		assert (k < P.GetCount());
		GenitFormsOfCardinal.push_back(P.GetWordForm(k));
	};
	return true;
};
예제 #29
0
파일: String.cpp 프로젝트: viticm/pap2
bool String::Divide(StringVector& sv, bool bDQM)
{
	static char Blanks[NUM_BLANKS] = {' ', '\t', '\r', '\n', '\0'};

	sv.clear();

	bool bEnterDQM = false;  // double quotation marks
	Common::String sTemp;
	for(unsigned int i = 0; i < GetSize(); ++i)
	{
		char c = at(i);
		bool bPush = false;

		if(bEnterDQM && bDQM)  // 如果是在双引号中
		{
			if(c == '"')  // 终结双引号
			{
				bPush = true;
				bEnterDQM = false;
			}
			else
			{
				sTemp += c;  // 直接追加字符串
			}
		}
		else  // 不在双引号中
		{
			if(c == '"' && bDQM)  // 要进入双引号中
			{
				bPush = true;
				bEnterDQM = true;
			}
			else  // 不是双引号,只是普通字符
			{
				bool bBlank = false;
				for(unsigned int j = 0; j < NUM_BLANKS; ++j)
				{
					if(c == Blanks[j])
					{
						bPush = true;
						bBlank = true;  // 是空白字符
						break;
					}
				}

				if(!bBlank)  // 不是空白字符
				{
					sTemp += c;
				}
			}
		}

		if(bPush)
		{
			if(!sTemp.empty())
			{
				sv.push_back(sTemp);
				sTemp.Clear();
			}
		}
	}

	if(bEnterDQM && bDQM)  // 还在双引号中,一定是出现了语法错误(漏了结束双引号)
	{
		//throw Common::Exception(Common::EL_GENERAL, "Extractor::DivideString", "Grammar error: a terminator of DQM expected!");
	}
	
	if(!sTemp.empty())
	{
		sv.push_back(sTemp);
		sTemp.Clear();
	}

	return true;
}
예제 #30
0
VOID CDataPool::InsertBasePropertyList(CEGUI::Window* pWindow)
{
	CRightPropList* pList = GetRightPropList();
	StringVector vec;

	//位置相关
	pList->CreateRootItem("PropertyPos","窗口位置大小相关","窗口位置大小相关集合");

	pList->InsertEditItem("UnifiedXPosition", "位置X{rx, ax}","",OTES_NORMAL,"UnifiedXPosition","PropertyPos");
	pList->InsertEditItem("UnifiedYPosition", "位置Y{ry, ay}","",OTES_NORMAL,"UnifiedYPosition","PropertyPos");
	pList->InsertEditItem("UnifiedWidth", "宽度{rw, aw}","",OTES_NORMAL,"UnifiedWidth","PropertyPos");
	pList->InsertEditItem("UnifiedHeight", "高度{rh, ah}","",OTES_NORMAL,"UnifiedHeight","PropertyPos");

	pList->InsertEditItem("UnifiedMaxSize", "窗口最大尺寸{{rw,aw},{rh,ah}}","",OTES_NORMAL,"UnifiedMaxSize","PropertyPos");
	pList->InsertEditItem("UnifiedMinSize", "窗口最小尺寸{{rw,aw},{rh,ah}}","",OTES_NORMAL,"UnifiedMinSize","PropertyPos");

	vec.push_back("");
	vec.push_back("Relative");
	vec.push_back("Absolute");
	vec.push_back("Inherited");
	pList->InsertComboItem("MetricsMode", "相对模式(Relative)随窗口变化自动缩放,绝对模式(Absolute),位置不会随父窗口变化而变化",vec, OTCS_NORMAL, "MetricsMode", "PropertyPos");

	//重要的设置
	pList->CreateRootItem("ImportantSet","重要设置","重要设置相关集合");
	pList->InsertEditItem("Name", "窗口Alpha","",OTES_NORMAL,"Name","ImportantSet");
	pList->InsertEditItem("Text", "窗口显示的文本","",OTES_NORMAL,"Text","ImportantSet");
	pList->InsertEditItem("Tooltip", "窗口Tooltip","",OTES_NORMAL,"Tooltip","ImportantSet");
	pList->InsertEditItem("ID", "窗口ID","",OTES_NORMAL,"ID","ImportantSet");
	pList->InsertEditItem("Alpha", "窗口Alpha","",OTES_NORMAL,"Alpha","ImportantSet");
	
	
	FontManager::FontIterator it = FontManager::getSingleton().getIterator();
	vec.clear();
	vec.push_back("");
	while ( !it.isAtEnd() )
	{
		vec.push_back(it.getCurrentKey().c_str());
		++it;
	}
	pList->InsertComboItem("Font", "窗口Font",vec, OTCS_NORMAL, "Font", "ImportantSet");

	vec.clear();
	vec.push_back("");
	vec.push_back("True");
	vec.push_back("False");
	pList->InsertComboItem("ClippedByParent", "是否被父窗口裁剪",vec, OTCS_NORMAL, "ClippedByParent", "ImportantSet");
	pList->InsertComboItem("Disabled", "是否Disable窗口",vec, OTCS_NORMAL, "Disabled", "ImportantSet");
	pList->InsertComboItem("Visible", "是否Disable窗口",vec, OTCS_NORMAL, "Visible", "ImportantSet");
	pList->InsertComboItem("RiseOnClick", "鼠标单击后是否将窗口提升到最高层",vec, OTCS_NORMAL, "RiseOnClick", "ImportantSet");

	
	//鼠标镂空
	pList->CreateRootItem("HollowMode","鼠标镂空相关","鼠标镂空相关集合");

	vec.clear();
	vec.push_back("");
	vec.push_back("True");
	vec.push_back("False");
	pList->InsertComboItem("MouseHollow", "所有鼠标操作都镂空",vec, OTCS_NORMAL, "MouseHollow", "HollowMode");
	pList->InsertComboItem("MouseMoveHollow", "镂空鼠标移动操作",vec, OTCS_NORMAL, "MouseMoveHollow", "HollowMode");
	pList->InsertComboItem("MouseLButtonHollow", "镂空鼠标左键操作",vec, OTCS_NORMAL, "MouseLButtonHollow", "HollowMode");
	pList->InsertComboItem("MouseRButtonHollow", "镂空鼠标右键操作",vec, OTCS_NORMAL, "MouseRButtonHollow", "HollowMode");

	//对齐方式
	pList->CreateRootItem("PropertyAlignmentMode","对齐方式相关","对齐方式相关集合");

	vec.clear();
	vec.push_back("");
	vec.push_back("Centre");
	vec.push_back("Bottom");
	vec.push_back("Top");
	pList->InsertComboItem("VerticalAlignment", "窗口竖直对齐方式",vec, OTCS_NORMAL, "VerticalAlignment", "PropertyAlignmentMode");

	vec.clear();
	vec.push_back("");
	vec.push_back("Centre");
	vec.push_back("Right");
	vec.push_back("Left");
	pList->InsertComboItem("HorizontalAlignment", "窗口水平对齐方式",vec, OTCS_NORMAL, "HorizontalAlignment", "PropertyAlignmentMode");

	//Hook模式
	pList->CreateRootItem("HookingMode","Hook模式","Hook模式集合");
	pList->InsertEditItem("HookPosition", "Hook的位置","",OTES_NORMAL,"HookPosition","HookingMode");

	vec.clear();
	vec.push_back("");
	vec.push_back("None");
	vec.push_back("Left");
	vec.push_back("Right");
	vec.push_back("Top");
	vec.push_back("Bottom");
	vec.push_back("LeftTop");
	vec.push_back("LeftBottom");
	vec.push_back("RightTop");
	vec.push_back("RightBottom");
	vec.push_back("Center");
	pList->InsertComboItem("HookMode", "定位到窗口的某个位置",vec, OTCS_NORMAL, "HookMode", "HookingMode");

	vec.clear();
	vec.push_back("");
	vec.push_back("Relative");
	vec.push_back("Absolute");
	vec.push_back("Inherited");
	pList->InsertComboItem("ZoomMode", "缩放模式Absolute和Relative",vec, OTCS_NORMAL, "ZoomMode", "HookingMode");

	//调用脚本添加基本属性
	//创建父窗口
	pList->CreateRootItem("OtherSets","其他属性","其他属性集合");

	vec.clear();
	vec.push_back("");
	vec.push_back("True");
	vec.push_back("False");
	pList->InsertComboItem("MouseButtonDownAutoRepeat", "鼠标事件是否自动重复",vec, OTCS_NORMAL, "MouseButtonDownAutoRepeat", "OtherSets");

	pList->InsertEditItem("AutoRepeatDelay", "重复延迟时间","",OTES_NORMAL,"AutoRepeatDelay","OtherSets");
	pList->InsertEditItem("AutoRepeatRate", "重复延迟时间","",OTES_NORMAL,"AutoRepeatRate","OtherSets");
	pList->InsertEditItem("MouseCursorImage", "图片作为鼠标(set:setname image:imagename)","",OTES_NORMAL,"MouseCursorImage","OtherSets");
	
		
	//调用脚本处理
	m_scriptModule.DoString("getBasePropList('OtherSets')");
	
	
	pList->ExpandAllItems();
}