Beispiel #1
0
/*
 * LoadRsc: Loads the RESOURCE_RSC_SPEC files (.rsc or .rsb).
 */
void LoadRsc(void)
{
   char file_load_path[MAX_PATH+FILENAME_MAX];
   char *filespec = ConfigStr(RESOURCE_RSC_SPEC);
   char *filepath = ConfigStr(PATH_RSC);

   int files_loaded = 0;
   sprintf(file_load_path, "%s%s", filepath, filespec);
   StringVector files;
   if (FindMatchingFiles(file_load_path, &files))
   {
      for (StringVector::iterator it = files.begin(); it != files.end(); ++it)
      {
         sprintf(file_load_path, "%s%s", filepath, it->c_str());

         if (RscFileLoad(file_load_path, EachLoadRsc))
         {
            if (stricmp(filespec, "*.rsb") == 0)
               LoadRSBHash(file_load_path);
            files_loaded++;
         }
         else
            eprintf("LoadRsc error loading %s\n", it->c_str());
      }
   }

   dprintf("LoadRsc loaded %i of %i found %s files\n",
      files_loaded, files.size(), filespec);

}
EStatusCode Type1ToCFFEmbeddedFontWriter::WriteStringIndex()
{
	
	mPrimitivesWriter.WriteCard16((unsigned short)mStrings.size());
	if(mStrings.size() > 0)
	{
		// calculate the total data size to determine the required offset size
		unsigned long totalSize=0;
		StringVector::iterator it = mStrings.begin();
		for(; it != mStrings.end(); ++it)
			totalSize += (unsigned long)it->size();
		
		Byte sizeOfOffset = GetMostCompressedOffsetSize(totalSize + 1);
		mPrimitivesWriter.WriteOffSize(sizeOfOffset);
		mPrimitivesWriter.SetOffSize(sizeOfOffset);
	
		unsigned long currentOffset = 1;

		// write the offsets
		for(it = mStrings.begin(); it != mStrings.end(); ++it)
		{
			mPrimitivesWriter.WriteOffset(currentOffset);
			currentOffset += (unsigned long)it->size();
		}
		mPrimitivesWriter.WriteOffset(currentOffset);

		// write the data
		for(it = mStrings.begin(); it != mStrings.end(); ++it)
			mFontFileStream.Write((const Byte*)(it->c_str()),it->size());
	}

	return mPrimitivesWriter.GetInternalState();
}
QStringList FaerieAnimationsDelegate::GetAnimationsList() {
	StringVector names = _collection->GetAnimationsNames();
	QStringList animationsList;
	for (StringVector::iterator i = names.begin(); i != names.end(); ++i) {
		animationsList.push_back(tr(i->c_str()));
	}
	return animationsList;
}
Beispiel #4
0
VmbErrorType EnumFeature::GetValues( const char **pRange, VmbUint32_t &rnSize )
{
    if ( NULL == m_pFeatureContainer )
    {
        return VmbErrorDeviceNotOpen;
    }

    VmbUint32_t nCount = 0;
    VmbError_t res = VmbFeatureEnumRangeQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &nCount );

    if (    VmbErrorSuccess == res
            && 0 < nCount )
    {
        std::vector<const char*> data( nCount );

        res = VmbFeatureEnumRangeQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &data[0], nCount, &nCount );

        if ( VmbErrorSuccess == res )
        {
            m_EnumStringValues.clear();

            for (   std::vector<const char*>::iterator iter = data.begin();
                    data.end() != iter;
                    ++iter )
            {
                m_EnumStringValues.push_back( std::string( *iter ));
            }

            if ( NULL == pRange )
            {
                rnSize = (VmbUint32_t)m_EnumStringValues.size();
                res = VmbErrorSuccess;
            }
            else if ( m_EnumStringValues.size() <= rnSize )
            {
                VmbUint32_t i = 0;
                for (   StringVector::iterator iter = m_EnumStringValues.begin();
                        m_EnumStringValues.end() != iter;
                        ++iter, ++i )
                {
                    pRange[i] = iter->c_str();
                }
                rnSize = (VmbUint32_t)m_EnumStringValues.size();
                res = VmbErrorSuccess;
            }
            else
            {
                res = VmbErrorMoreData;
            }
        }
    }

    return (VmbErrorType)res;
}
    //FindFiles
    Int DirectoryArchiveHandler::FindFiles( const String& archiveLocation, StringVector* files, bool recurse )
    {
        // Find the files:
        Int count = searchDirectory( archiveLocation, files, recurse );

        // Go through the files and remove the directory from the name
        StringVector::iterator fileIter = files->begin();
        Int length = archiveLocation.length() + 1;
        for ( fileIter; fileIter != files->end(); fileIter++ )
        {
            fileIter->erase( 0, length );
        }
        return count;
    }
	//bool stringCompare( const string &left, const string &right )
	//{
	//   for( string::const_iterator lit = left.begin(), rit = right.begin(); lit != left.end() && rit != right.end(); ++lit, ++rit )
	//      if( tolower( *lit ) < tolower( *rit ) )
	//         return true;
	//      else if( tolower( *lit ) > tolower( *rit ) )
	//         return false;
	//   if( left.size() < right.size() )
	//      return true;
	//   return false;
	//}
	StringVector CDirectoryManagerBase::GetDirectoriesFromString(const std::string& directoryListString)
	{
		StringVector tmp1 = Tokenize(directoryListString, "|");
		StringVector tmp2;
		for (StringVector::iterator it = tmp1.begin(); it != tmp1.end(); it++)
		{
			Trim(*it);
			if (!it->empty())
			{
				if (!IsPathEndOk(*it))
					*it += '\\';

				*it = SimplifyFilePath(*it);
				if (tmp2.Find(*it, false) == UNKNOWN_POS)
					tmp2.push_back(*it);
			}
		}

		return tmp2;
	}
Beispiel #7
0
bool parseIntegerVec(std::string str, IntegerVec& intVector)
{
	StringVector strVector = explodeString(str, ";");
	IntegerVec tmpIntVector;
	for(StringVector::iterator it = strVector.begin(); it != strVector.end(); ++it)
	{
		tmpIntVector = vectorAtoi(explodeString((*it), "-"));
		if(!tmpIntVector[0] && it->substr(0, 1) != "0")
			continue;

		intVector.push_back(tmpIntVector[0]);
		if(tmpIntVector.size() > 1)
		{
			while(tmpIntVector[0] < tmpIntVector[1])
				intVector.push_back(++tmpIntVector[0]);
		}
	}

	return true;
}
Beispiel #8
0
void NotesHelper::CreateNotesMessage(const std::tstring& recipients, const std::tstring& subject, StringVector& body, LNMailMessage &message)
{
	LNSTATUS status = Session::Instance()->GetNotesSession().CreateMailMessage(&message);
	if(NOERROR != status)
	{
		std::vector<char> errorbuffer(LNERROR_MESSAGE_LENGTH);
		LNINT charCount = LNGetErrorMessage(status, &errorbuffer[0]);
		throw CppUnitException(std::tstring(errorbuffer.begin(), errorbuffer.begin() + charCount), __LINE__, _T(__FILE__));	
	}

	message.SendTo(Workshare::Conversions::W22LNString(recipients.c_str()));
	message.SetSubject(Workshare::Conversions::W22LNString(subject.c_str()));
		
	LNRichText rtBody;
	message.GetBody(&rtBody);

	for(StringVector::iterator bodyIter = body.begin(); bodyIter != body.end(); ++bodyIter)
	{
		rtBody.Append(Workshare::Conversions::W22LNString(bodyIter->c_str()));
	}
}
Beispiel #9
0
int main ( )
{

	PME regex ( ", " );
	int i = regex.split ( "very, very2, tired" );

	for ( int j = 0; j < i; j++ ) {
		
		printf ( "%s\n", regex [ j ].c_str ( ) );

	}

	StringVector sv = regex.GetStringVector ( );
	
	for ( StringVector::iterator i = sv.begin ( );
		  i != sv.end ( );
		  i++ ) {

		printf ( "%s\n", i->c_str ( ) );

	}


	PME match ( "([a-z])([0-9])([A-Z])" );

	match.match ( "b2Z" );

	sv = match.GetStringVector ( );

	for ( StringVector::iterator i = sv.begin ( );
		  i != sv.end ( );
		  i++ ) {

		printf ( "%s\n", i->c_str ( ) );

	}

}
Beispiel #10
0
void LoadRsc(void)
{
	char file_load_path[MAX_PATH+FILENAME_MAX];
	
	int files_loaded = 0;
	StringVector files;
	if (FindMatchingFiles(ConfigStr(PATH_RSC), RSC_EXTENSION, &files))
	{
		for (StringVector::iterator it = files.begin(); it != files.end(); ++it)
		{
			sprintf(file_load_path,"%s%s",ConfigStr(PATH_RSC), it->c_str());
			
			if (RscFileLoad(file_load_path,EachLoadRsc))
				files_loaded++;
			else
				eprintf("LoadRsc error loading %s\n", it->c_str());
		}
	}
	
	/*
	dprintf("LoadRsc loaded %i of %i found .rsc files\n",files_loaded,files.size());
	*/
}
Beispiel #11
0
void LoadBof(void)
{
	char file_load_path[MAX_PATH+FILENAME_MAX];
	char file_copy_path[MAX_PATH+FILENAME_MAX];
	
	int files_loaded = 0;
	
	sprintf(file_load_path,"%s%s",ConfigStr(PATH_BOF),BOF_SPEC);
   StringVector files;
   if (FindMatchingFiles(file_load_path, &files))
   {
      for (StringVector::iterator it = files.begin(); it != files.end(); ++it)
      {
			sprintf(file_load_path,"%s%s",ConfigStr(PATH_BOF), it->c_str());
			sprintf(file_copy_path,"%s%s",ConfigStr(PATH_MEMMAP), it->c_str());
			if (BlakMoveFile(file_load_path,file_copy_path))
				files_loaded++;
      }
   }
	
	/*
	if (!files.empty())
	dprintf("LoadBof moved in %i of %i found new .bof files\n",files_loaded,files.size());
	*/

	//dprintf("starting to load bof files\n");
	files_loaded = 0;
	
	sprintf(file_load_path,"%s%s",ConfigStr(PATH_MEMMAP),BOF_SPEC);
   if (FindMatchingFiles(file_load_path, &files))
   {
      for (StringVector::iterator it = files.begin(); it != files.end(); ++it)
      {
			sprintf(file_load_path,"%s%s",ConfigStr(PATH_MEMMAP), it->c_str());
			
			if (LoadBofName(file_load_path))
				files_loaded++;
			else
				eprintf("LoadAllBofs can't load %s\n", it->c_str());
		}
	}
	
	SetClassesSuperPtr();
	SetClassVariables();
	SetMessagesPropagate();

	dprintf("LoadBof loaded %i of %i found .bof files\n",files_loaded,files.size());
}
    //---------------------------------------------------------------------
    void GLSLProgramManagerCommon::parseIndividualConstant(const String& src, GpuNamedConstants& defs,
                                                             String::size_type currPos,
                                                             const String& filename, GpuSharedParametersPtr sharedParams)
    {
        GpuConstantDefinition def;
        String paramName = "";
        String::size_type endPos = src.find(";", currPos);
        String line = src.substr(currPos, endPos - currPos);

        // Remove spaces before opening square braces, otherwise
        // the following split() can split the line at inappropriate
        // places (e.g. "vec3 something [3]" won't work).
        for (String::size_type sqp = line.find (" ["); sqp != String::npos;
             sqp = line.find (" ["))
            line.erase (sqp, 1);
        // Split into tokens
        StringVector parts = StringUtil::split(line, ", \t\r\n");

        for (StringVector::iterator i = parts.begin(); i != parts.end(); ++i)
        {
            // Is this a type?
            StringToEnumMap::iterator typei = mTypeEnumMap.find(*i);
            if (typei != mTypeEnumMap.end())
            {
                completeDefInfo(typei->second, def);
            }
            else
            {
                // if this is not a type, and not empty, it should be a name
                StringUtil::trim(*i);
                if (i->empty()) continue;

                // Skip over precision keywords
                if(StringUtil::match((*i), "lowp") ||
                   StringUtil::match((*i), "mediump") ||
                   StringUtil::match((*i), "highp"))
                    continue;

                String::size_type arrayStart = i->find("[", 0);
                if (arrayStart != String::npos)
                {
                    // potential name (if butted up to array)
                    String name = i->substr(0, arrayStart);
                    StringUtil::trim(name);
                    if (!name.empty())
                        paramName = name;

                    String::size_type arrayEnd = i->find("]", arrayStart);
                    String arrayDimTerm = i->substr(arrayStart + 1, arrayEnd - arrayStart - 1);
                    StringUtil::trim(arrayDimTerm);
                    // the array term might be a simple number or it might be
                    // an expression (e.g. 24*3) or refer to a constant expression
                    // we'd have to evaluate the expression which could get nasty
                    // TODO
                    def.arraySize = StringConverter::parseInt(arrayDimTerm);
                }
                else
                {
                    paramName = *i;
                    def.arraySize = 1;
                }

                // Name should be after the type, so complete def and add
                // We do this now so that comma-separated params will do
                // this part once for each name mentioned
                if (def.constType == GCT_UNKNOWN)
                {
                    LogManager::getSingleton().logMessage("Problem parsing the following GLSL Uniform: '"
                                                          + line + "' in file " + filename);
                    // next uniform
                    break;
                }

                // Special handling for shared parameters
                if(sharedParams.isNull())
                {
                    // Complete def and add
                    // increment physical buffer location
                    def.logicalIndex = 0; // not valid in GLSL
                    if (def.isFloat())
                    {
                        def.physicalIndex = defs.floatBufferSize;
                        defs.floatBufferSize += def.arraySize * def.elementSize;
                    }
                    else
                    {
                        def.physicalIndex = defs.intBufferSize;
                        defs.intBufferSize += def.arraySize * def.elementSize;
                    }
                    defs.map.insert(GpuConstantDefinitionMap::value_type(paramName, def));

                    // Generate array accessors
                    defs.generateConstantDefinitionArrayEntries(paramName, def);
                }
                else
                {
                    try
                    {
                        const GpuConstantDefinition &sharedDef = sharedParams->getConstantDefinition(paramName);
                        (void)sharedDef;    // Silence warning
                    }
                    catch (Exception& e)
                    {
                        // This constant doesn't exist so we'll create a new one
                        sharedParams->addConstantDefinition(paramName, def.constType);
                    }
                }
            }
        }
    }
	//---------------------------------------------------------------------
	void GLSLESProgramManagerCommon::extractConstantDefs(const String& src,
		GpuNamedConstants& defs, const String& filename)
	{
		// Parse the output string and collect all uniforms
		// NOTE this relies on the source already having been preprocessed
		// which is done in GLSLESProgram::loadFromSource
		String line;
		String::size_type currPos = src.find("uniform");
		while (currPos != String::npos)
		{
			GpuConstantDefinition def;
			String paramName;

			// Now check for using the word 'uniform' in a larger string & ignore
			bool inLargerString = false;
			if (currPos != 0)
			{
				char prev = src.at(currPos - 1);
				if (prev != ' ' && prev != '\t' && prev != '\r' && prev != '\n'
					&& prev != ';')
					inLargerString = true;
			}
			if (!inLargerString && currPos + 7 < src.size())
			{
				char next = src.at(currPos + 7);
				if (next != ' ' && next != '\t' && next != '\r' && next != '\n')
					inLargerString = true;
			}

			// skip 'uniform'
			currPos += 7;

			if (!inLargerString)
			{
				// find terminating semicolon
				String::size_type endPos = src.find(";", currPos);
				if (endPos == String::npos)
				{
					// problem, missing semicolon, abort
					break;
				}
				line = src.substr(currPos, endPos - currPos);

				// Remove spaces before opening square braces, otherwise
				// the following split() can split the line at inappropriate
				// places (e.g. "vec3 something [3]" won't work).
				for (String::size_type sqp = line.find (" ["); sqp != String::npos;
					 sqp = line.find (" ["))
					line.erase (sqp, 1);
				// Split into tokens
				StringVector parts = StringUtil::split(line, ", \t\r\n");

				for (StringVector::iterator i = parts.begin(); i != parts.end(); ++i)
				{
					// Is this a type?
					StringToEnumMap::iterator typei = mTypeEnumMap.find(*i);
					if (typei != mTypeEnumMap.end())
					{
						completeDefInfo(typei->second, def);
					}
					else
					{
						// if this is not a type, and not empty, it should be a name
						StringUtil::trim(*i);
						if (i->empty()) continue;

                        // Skip over precision keywords
                        if(StringUtil::match((*i), "lowp") ||
                           StringUtil::match((*i), "mediump") ||
                           StringUtil::match((*i), "highp"))
                            continue;

						String::size_type arrayStart = i->find("[", 0);
						if (arrayStart != String::npos)
						{
							// potential name (if butted up to array)
							String name = i->substr(0, arrayStart);
							StringUtil::trim(name);
							if (!name.empty())
								paramName = name;

							String::size_type arrayEnd = i->find("]", arrayStart);
							String arrayDimTerm = i->substr(arrayStart + 1, arrayEnd - arrayStart - 1);
							StringUtil::trim(arrayDimTerm);
							// the array term might be a simple number or it might be
							// an expression (e.g. 24*3) or refer to a constant expression
							// we'd have to evaluate the expression which could get nasty
							// TODO
							def.arraySize = StringConverter::parseUnsignedLong(arrayDimTerm);

						}
						else
						{
							paramName = *i;
							def.arraySize = 1;
						}

						// Name should be after the type, so complete def and add
						// We do this now so that comma-separated params will do
						// this part once for each name mentioned 
						if (def.constType == GCT_UNKNOWN)
						{
							LogManager::getSingleton().logMessage(
								"Problem parsing the following GLSL Uniform: '"
								+ line + "' in file " + filename);
							// next uniform
							break;
						}

						// Complete def and add
						// increment physical buffer location
						def.logicalIndex = 0; // not valid in GLSL
						if (def.isFloat())
						{
							def.physicalIndex = defs.floatBufferSize;
							defs.floatBufferSize += def.arraySize * def.elementSize;
						}
						else
						{
							def.physicalIndex = defs.intBufferSize;
							defs.intBufferSize += def.arraySize * def.elementSize;
						}
						defs.map.insert(GpuConstantDefinitionMap::value_type(paramName, def));

						// Generate array accessors
						defs.generateConstantDefinitionArrayEntries(paramName, def);
					}

				}

			} // not commented or a larger symbol

			// Find next one
			currPos = src.find("uniform", currPos);
		}
		
	}