Example #1
0
	//-----------------------------------------------------------------------
    void StringUtil::trim(String& str, bool left, bool right)
    {
        /*
        size_t lspaces, rspaces, len = length(), i;

        lspaces = rspaces = 0;

        if( left )
        {
            // Find spaces / tabs on the left
            for( i = 0;
                i < len && ( at(i) == ' ' || at(i) == '\t' || at(i) == '\r');
                ++lspaces, ++i );
        }
        
        if( right && lspaces < len )
        {
            // Find spaces / tabs on the right
            for( i = len - 1;
                i >= 0 && ( at(i) == ' ' || at(i) == '\t' || at(i) == '\r');
                rspaces++, i-- );
        }

        *this = substr(lspaces, len-lspaces-rspaces);
        */
        static const String delims = " \t\r";
        if(right)
            str.erase(str.find_last_not_of(delims)+1); // trim right
        if(left)
            str.erase(0, str.find_first_not_of(delims)); // trim left
    }
Example #2
0
	StringList String::split(String splitBy, int limitCount){
		StringList MyStrList;
		unsigned int Iter = 0;
		String MyStr = *this;
		String Current;

		for(unsigned int i = 0; i < MyStr.length(); i++){
			if(MyStr[i] == splitBy[Iter]){
				Iter++;
			}
			else{
				//Break a partial match
				Iter = 0;
			}

			Current += MyStr[i];

			if(Iter == splitBy.length()){
				if(limitCount != 0 && MyStrList.size() == limitCount)
					continue;
				Current.erase(Current.length() - Iter, Current.length());
				MyStrList.push_back(Current);
				Current.clear();
				Iter = 0; 
			}
		}
		Current.erase(Current.length() - Iter, Current.length());
		MyStrList.push_back(Current);

		return MyStrList;

	};
Example #3
0
	void StringUtil::trim(String& str, BOOL left, BOOL right)
	{
		static const String delims = " \t\r";
		if (right)
		{
			str.erase(str.find_last_not_of(delims) + 1);
		}
		if (left)
		{
			str.erase(0, str.find_first_not_of(delims));
		}
	}
Example #4
0
std::list<String>
String::separateByChar(char separator) const
{
    /**
     *  This function breaks up a string into sections before and after a particular
     *  character. If, for instance, *this = "ab|c|d||efg|h", and separator = '|',
     *  separateStringByChar will return a vector containing "ab", "c", "d", "",
     *  "efg", and "h". Note that despite the fact there is a | missing from the h
     *  at the end, "h" is still returned. By this logic, if the string contains no
     *  | at all, e.g., if it were "abcdefgh", this function would simply return
     *  "abcdefgh".
    */

    //Vector to return.
    String str = *this;

    std::list<String> strList;
    unsigned separatorPos;

    while ((separatorPos = str.find(separator)) != std::string::npos)
    {
        strList.push_back(str.substr(0, separatorPos));
        str.erase(0, separatorPos + 1);
    }

    strList.push_back(str);

    return strList;
}
Example #5
0
String
strutil_findurl(String& str, String& url)
{
   static URLDetector s_detector;

   // the return value: the part of the text before the URL
   String before;

   int len;
   int pos = s_detector.FindURL(str, len);

   if ( pos == -1 )
   {
      // no URLs found
      str.swap(before);
      str.clear();
      url.clear();
   }
   else // found an URL
   {
      before = str.substr(0, pos);
      url = str.substr(pos, len);

      str.erase(0, pos + len);
   }

   return before;
}
Example #6
0
String HTTPClient::query_string_from_dict(const Dictionary &p_dict) {
	String query = "";
	Array keys = p_dict.keys();
	for (int i = 0; i < keys.size(); ++i) {
		String encoded_key = String(keys[i]).http_escape();
		Variant value = p_dict[keys[i]];
		switch (value.get_type()) {
			case Variant::ARRAY: {
				// Repeat the key with every values
				Array values = value;
				for (int j = 0; j < values.size(); ++j) {
					query += "&" + encoded_key + "=" + String(values[j]).http_escape();
				}
				break;
			}
			case Variant::NIL: {
				// Add the key with no value
				query += "&" + encoded_key;
				break;
			}
			default: {
				// Add the key-value pair
				query += "&" + encoded_key + "=" + String(value).http_escape();
			}
		}
	}
	query.erase(0, 1);
	return query;
}
Example #7
0
String Path::ExtractPathFromCmdLine(String& input)
{
	String r;
	input.Trim();
	bool q = input[0] == '"';
	size_t i = q ? 1 : 0;
	while(i < input.size())
	{
		if(q)
		{
			if(input[i] == '"')
			{
				break;
			}
		}
		else
		{
			if(input[i] == ' ')
			{
				break;
			}
		}
		r += input[i];
		i++;
	}
	input.erase(input.begin(), input.begin() + r.size() + (q ? 2 : 0));
	input.Trim();
	return r;
}
Example #8
0
String HTTPClient::query_string_from_dict(const Dictionary &p_dict) {
	String query = "";
	Array keys = p_dict.keys();
	for (int i = 0; i < keys.size(); ++i) {
		query += "&" + String(keys[i]).http_escape() + "=" + String(p_dict[keys[i]]).http_escape();
	}
	query.erase(0, 1);
	return query;
}
Example #9
0
Vector3 EngineUtil::stringToVector3(String data, bool removeFirstOnOverload) {
	int posX = 0;
	int posY = 0;
	int posZ = 0;

	float partX = 0;
	float partY = 0;
	float partZ = 0;

	String sPartX = "";
	String sPartY = "";
	String sPartZ = "";
	
	//verify if it have 4 values and remove first
	if (removeFirstOnOverload == true) {
		if ( EngineUtil::stringCount(data, " ") == 3 ) {
			posX   = data.find(" ");
			sPartX = data.substr(0, posX); 
			data   = data.erase(0, posX+1);

			posX   = 0;
			partX  = 0;
			sPartX = "";
		}
	}
	
	//separate the values and mount the vector
	posX   = data.find(" ");
	sPartX = data.substr(0, posX); 
	data   = data.erase(0, posX+1);

	posY   = data.find(" ");
	sPartY = data.substr(0, posY); 
	data   = data.erase(0, posY+1);

	sPartZ = data;
	
	partX  = atof(sPartX.c_str());
	partY  = atof(sPartY.c_str());
	partZ  = atof(sPartZ.c_str());

	return Vector3(partX, partY, partZ);
}
Example #10
0
String _cleanPath(const String& name) {
	String path = name;
	for (size_t i = 0; i < path.size(); ++i) {
		auto& c = path[i];
		if (c == ':' || c == '\\' || c == '/') { //TODO more invalid chars
			path.erase(path.begin() + i);
			--i;
		}
	}

	return path;
}
Example #11
0
String URI::toNativePath(Utils::SystemType type) const
{
//		String scheme, authority, path, query, fragment;
//		parseUriRef(uriRef, scheme, authority, path, query, fragment);

    // Make sure we have a file scheme URI, or that it doesn't have a scheme
    if (!mScheme.empty()  &&  mScheme != "file")
        return "";

    String filePath;
    String currentPath ( mPath );

    if (type == Utils::WINDOWS) {
        if (!mAuthority.empty())
            filePath += String("\\\\") + mAuthority; // UNC path

        // Replace two leading slashes with one leading slash, so that
        // ///otherComputer/file.dae becomes //otherComputer/file.dae and
        // //folder/file.dae becomes /folder/file.dae
        if (currentPath.length() >= 2  &&  currentPath[0] == '/'  &&  currentPath[1] == '/')
            currentPath.erase(0, 1);

        // Convert "/C:/" to "C:/"
        if (currentPath.length() >= 3  &&  currentPath[0] == '/'  &&  currentPath[2] == ':')
            currentPath.erase(0, 1);

        // Convert forward slashes to back slashes
        Utils::stringFindAndReplace(currentPath, "/", "\\");
    }

    filePath += currentPath;

    // Replace % encoded characters
    filePath = URI::uriDecode ( filePath );

    return filePath;
}
Example #12
0
	String CVarRecord::generateSyncedStringRepresentation() const {
		// Replace the old value with the new.
		std::stringstream ss;

		if (cvar.getType() == sani::cvarlang::ValueType::StringVal) {
			String value;
			cvar.read(value);

			ss << value;
		} else if (cvar.getType() == sani::cvarlang::ValueType::IntVal) {
			int32 value = 0;
			cvar.read(value);

			ss << value;
		} else if (cvar.getType() == sani::cvarlang::ValueType::FloatVal) {
			float32 value = 0.0f;
			cvar.read(value);

			ss << value;
		} else if (cvar.getType() == sani::cvarlang::ValueType::DoubleVal) {
			float64 value = 0.0;
			cvar.read(value);

			ss << value;
		}

		// Create the new representation.
		const String newValue = ss.str();
		String newRepresentation = token.getLine();

		if (newValue.size() < originalValue.size()) {
			// Remove chars.
			const size_t diff = originalValue.size() - newValue.size();

			newRepresentation.erase(indexOfValue, diff);
		} else if (newValue.size() > originalValue.size()) {
			// Add chars.
			const size_t diff = newValue.size() - originalValue.size();
			
			String insertion;
			insertion.resize(diff, ' ');

			newRepresentation.insert(indexOfValue, insertion);
		}

		newRepresentation.replace(indexOfValue, newValue.size(), newValue);

		return newRepresentation;
	}
void Document::loadFromCurrenttDir( const String& fileName_ )
{
	FRL_EXCEPT_GUARD();
	String currDir = io::fs::getCurrentDirectory();
	io::fs::addSlashToEndPath( currDir );
	fileName = currDir + fileName_;
	String buffer;
	loadFileToString( fileName, buffer );
	buffer.erase( std::remove_if( buffer.begin(), buffer.end(), private_::isCRLF ), buffer.end() ); // remove CRLF
	parseHeader( buffer );
	NodesList tmpMap = Parser::getSubNodes( buffer );
	if( tmpMap.size() > 1 )
		FRL_THROW_S_CLASS( Document::BrokenXML ); // must be one root node
	root = (*tmpMap.begin());
}
 void CompNovoIdentificationBase::permute_(String prefix, String s, set<String> & permutations)
 {
   if (s.size() <= 1)
   {
     permutations.insert(prefix + s);
   }
   else
   {
     for (String::Iterator p = s.begin(); p < s.end(); p++)
     {
       char c = *p;
       p = s.erase(p);
       permute_(prefix + c, s, permutations);
       s.insert(p, c);
     }
   }
 }
Example #15
0
String Path::ReplaceExtension(String path, String newExt)
{
	newExt.TrimFront('.');

	// Remove everything in the extension and the dot
	size_t dotPos = path.find_last_of(".");
	if(dotPos != -1)
	{
		path.erase(path.begin() + dotPos, path.end());
	}

	if(newExt.empty())
		return path;

	path.push_back('.');
	path += newExt;

	return path;
}
String io::readTrailingSpaces(ID3_Reader& reader, size_t len)
{
  io::WindowedReader wr(reader, len);
  String str;
  String spaces;
  str.reserve(len);
  spaces.reserve(len);
  while (!wr.atEnd())
  {
    ID3_Reader::char_type ch = wr.readChar();
    if (ch == '\0' || ch == ' ')
    {
      spaces += ch;
    }
    else
    {
      str += spaces + (char) ch;
      spaces.erase();
    }
  }
  return str;
}
    //---------------------------------------------------------------------
    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);
                    }
                }
            }
        }
    }
Example #18
0
// This is all fancy because it only creates one directory at a time,
// starting with the first missing subdirectory
bool ff::CreateDirectory(StringRef path)
{
	String szDrive;
	String szRealPath = CanonicalizePath(path);
	Vector<String> paths;

	if (szRealPath.empty())
	{
		return false;
	}
	else if (!wcsncmp(szRealPath.c_str(), L"\\\\.\\", 4))
	{
		// ignore physical paths
		return false;
	}
	else if (!wcsncmp(szRealPath.c_str(), L"\\\\", 2))
	{
		// UNC share, find the slash after the share name
		const wchar_t *szSlash = wcschr(szRealPath.c_str() + 2, '\\');
		szSlash = szSlash ? wcschr(szSlash + 1, '\\') : nullptr;

		if (!szSlash)
		{
			// can't create a server or share name
			return false;
		}

		szDrive = szRealPath.substr(0, szSlash - szRealPath.c_str() + 1);
		szRealPath.erase(0, szDrive.size());
	}
	else if (isalpha(szRealPath[0]) &&
		szRealPath[1] == ':' &&
		szRealPath[2] == '\\')
	{
		// absolute drive path
		szDrive = szRealPath.substr(0, 3);
		szRealPath.erase(0, 3);
	}
	else if (szRealPath[0] == '\\')
	{
		// relative drive path
		szDrive = L"\\";
		szRealPath.erase(0, 1);
	}
	else
	{
		// relative to the current directory
	}

	if (szRealPath.empty())
	{
		// nothing to create
		return false;
	}

	// Create the chain of parent directories
	{
		LockMutex crit(GCS_FILE_UTIL);

		for (; szRealPath.size() && !DirectoryExists(szDrive + szRealPath);
			StripPathTail(szRealPath))
		{
			paths.Push(szDrive + szRealPath);
		}

		for (size_t i = PreviousSize(paths.Size()); i != INVALID_SIZE; i = PreviousSize(i))
		{
			szRealPath = CanonicalizePath(paths[i], true);

			if (!::CreateDirectory(szRealPath.c_str(), nullptr))
			{
				assertRetVal(::GetLastError() == ERROR_ALREADY_EXISTS, false);
			}
		}
	}

	return true;
}
Example #19
0
static void handle_crash(int sig) {
	if (OS::get_singleton() == NULL) {
		abort();
	}

	void *bt_buffer[256];
	size_t size = backtrace(bt_buffer, 256);
	String _execpath = OS::get_singleton()->get_executable_path();

	String msg;
	const ProjectSettings *proj_settings = ProjectSettings::get_singleton();
	if (proj_settings) {
		msg = proj_settings->get("debug/settings/crash_handler/message");
	}

	// Dump the backtrace to stderr with a message to the user
	fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig);

	if (OS::get_singleton()->get_main_loop())
		OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH);

	fprintf(stderr, "Dumping the backtrace. %ls\n", msg.c_str());
	char **strings = backtrace_symbols(bt_buffer, size);
	if (strings) {
		for (size_t i = 1; i < size; i++) {
			char fname[1024];
			Dl_info info;

			snprintf(fname, 1024, "%s", strings[i]);

			// Try to demangle the function name to provide a more readable one
			if (dladdr(bt_buffer[i], &info) && info.dli_sname) {
				if (info.dli_sname[0] == '_') {
					int status;
					char *demangled = abi::__cxa_demangle(info.dli_sname, NULL, 0, &status);

					if (status == 0 && demangled) {
						snprintf(fname, 1024, "%s", demangled);
					}

					if (demangled)
						free(demangled);
				}
			}

			List<String> args;

			char str[1024];
			snprintf(str, 1024, "%p", bt_buffer[i]);
			args.push_back(str);
			args.push_back("-e");
			args.push_back(_execpath);

			String output = "";

			// Try to get the file/line number using addr2line
			int ret;
			Error err = OS::get_singleton()->execute(String("addr2line"), args, true, NULL, &output, &ret);
			if (err == OK) {
				output.erase(output.length() - 1, 1);
			}

			fprintf(stderr, "[%ld] %s (%ls)\n", i, fname, output.c_str());
		}

		free(strings);
	}
	fprintf(stderr, "-- END OF BACKTRACE --\n");

	// Abort to pass the error to the OS
	abort();
}
Example #20
0
	//---------------------------------------------------------------------
	void CgProgram::recurseParams(CGparameter parameter, size_t contextArraySize)
	{
		while (parameter != 0)
		{
			// Look for uniform parameters only
			// Don't bother enumerating unused parameters, especially since they will
			// be optimised out and therefore not in the indexed versions
			CGtype paramType = cgGetParameterType(parameter);

			if (cgGetParameterVariability(parameter) == CG_UNIFORM &&
				paramType != CG_SAMPLER1D &&
				paramType != CG_SAMPLER2D &&
				paramType != CG_SAMPLER3D &&
				paramType != CG_SAMPLERCUBE &&
				paramType != CG_SAMPLERRECT &&
				cgGetParameterDirection(parameter) != CG_OUT && 
				cgIsParameterReferenced(parameter))
			{
				int arraySize;

				switch(paramType)
				{
				case CG_STRUCT:
					recurseParams(cgGetFirstStructParameter(parameter));
					break;
				case CG_ARRAY:
					// Support only 1-dimensional arrays
					arraySize = cgGetArraySize(parameter, 0);
					recurseParams(cgGetArrayParameter(parameter, 0), (size_t)arraySize);
					break;
				default:
					// Normal path (leaf)
					String paramName = cgGetParameterName(parameter);
					size_t logicalIndex = cgGetParameterResourceIndex(parameter);

					// Get the parameter resource, to calculate the physical index
					CGresource res = cgGetParameterResource(parameter);
					bool isRegisterCombiner = false;
					size_t regCombinerPhysicalIndex = 0;
					switch (res)
					{
					case CG_COMBINER_STAGE_CONST0:
						// register combiner, const 0
						// the index relates to the texture stage; store this as (stage * 2) + 0
						regCombinerPhysicalIndex = logicalIndex * 2;
						isRegisterCombiner = true;
						break;
					case CG_COMBINER_STAGE_CONST1:
						// register combiner, const 1
						// the index relates to the texture stage; store this as (stage * 2) + 1
						regCombinerPhysicalIndex = (logicalIndex * 2) + 1;
						isRegisterCombiner = true;
						break;
					default:
						// normal constant
						break;
					}

					// Trim the '[0]' suffix if it exists, we will add our own indexing later
					if (StringUtil::endsWith(paramName, "[0]", false))
					{
						paramName.erase(paramName.size() - 3);
					}


					GpuConstantDefinition def;
					def.arraySize = contextArraySize;
					mapTypeAndElementSize(paramType, isRegisterCombiner, def);

					if (def.constType == GCT_UNKNOWN)
					{
						LogManager::getSingleton().logMessage(
							"Problem parsing the following Cg Uniform: '"
							+ paramName + "' in file " + mName);
						// next uniform
						parameter = cgGetNextParameter(parameter);
						continue;
					}
					if (isRegisterCombiner)
					{
						def.physicalIndex = regCombinerPhysicalIndex;
					}
					else
					{
						// base position on existing buffer contents
						if (def.isFloat())
						{
							def.physicalIndex = mFloatLogicalToPhysical->bufferSize;
						}
						else
						{
							def.physicalIndex = mIntLogicalToPhysical->bufferSize;
						}
					}

					def.logicalIndex = logicalIndex;
					if( mParametersMap.find(paramName) == mParametersMap.end())
					{
						mParametersMap.insert(GpuConstantDefinitionMap::value_type(paramName, def));
						mParametersMapSizeAsBuffer += sizeof(size_t);
						mParametersMapSizeAsBuffer += paramName.size();
						mParametersMapSizeAsBuffer += sizeof(GpuConstantDefinition);
					}

					// Record logical / physical mapping
					if (def.isFloat())
					{
											OGRE_LOCK_MUTEX(mFloatLogicalToPhysical->mutex);
						mFloatLogicalToPhysical->map.insert(
							GpuLogicalIndexUseMap::value_type(def.logicalIndex, 
								GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
						mFloatLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
					}
					else
					{
											OGRE_LOCK_MUTEX(mIntLogicalToPhysical->mutex);
						mIntLogicalToPhysical->map.insert(
							GpuLogicalIndexUseMap::value_type(def.logicalIndex, 
								GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
						mIntLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
					}

					break;
				}                   
			}

			// now handle uniform samplers. This is needed to fix their register positions
			// if delegating to a GLSL shader.
			if (mDelegate && cgGetParameterVariability(parameter) == CG_UNIFORM && (
				paramType == CG_SAMPLER1D ||
				paramType == CG_SAMPLER2D ||
				paramType == CG_SAMPLER3D ||
				paramType == CG_SAMPLERCUBE ||
				paramType == CG_SAMPLERRECT) &&
				cgGetParameterDirection(parameter) != CG_OUT && 
				cgIsParameterReferenced(parameter))
			{
				String paramName = cgGetParameterName(parameter);
				CGresource res = cgGetParameterResource(parameter);
				int pos = -1;
				switch (res)
				{
				case CG_TEXUNIT0: pos = 0; break;
				case CG_TEXUNIT1: pos = 1; break;
				case CG_TEXUNIT2: pos = 2; break;
				case CG_TEXUNIT3: pos = 3; break;
				case CG_TEXUNIT4: pos = 4; break;
				case CG_TEXUNIT5: pos = 5; break;
				case CG_TEXUNIT6: pos = 6; break;
				case CG_TEXUNIT7: pos = 7; break;
				case CG_TEXUNIT8: pos = 8; break;
				case CG_TEXUNIT9: pos = 9; break;
				case CG_TEXUNIT10: pos = 10; break;
				case CG_TEXUNIT11: pos = 11; break;
				case CG_TEXUNIT12: pos = 12; break;
				case CG_TEXUNIT13: pos = 13; break;
				case CG_TEXUNIT14: pos = 14; break;
				case CG_TEXUNIT15: pos = 15; break;
#if(CG_VERSION_NUM >= 3000)
				case CG_TEXUNIT16: pos = 16; break;
				case CG_TEXUNIT17: pos = 17; break;
				case CG_TEXUNIT18: pos = 18; break;
				case CG_TEXUNIT19: pos = 19; break;
				case CG_TEXUNIT20: pos = 20; break;
				case CG_TEXUNIT21: pos = 21; break;
				case CG_TEXUNIT22: pos = 22; break;
				case CG_TEXUNIT23: pos = 23; break;
				case CG_TEXUNIT24: pos = 24; break;
				case CG_TEXUNIT25: pos = 25; break;
				case CG_TEXUNIT26: pos = 26; break;
				case CG_TEXUNIT27: pos = 27; break;
				case CG_TEXUNIT28: pos = 28; break;
				case CG_TEXUNIT29: pos = 29; break;
				case CG_TEXUNIT30: pos = 30; break;
				case CG_TEXUNIT31: pos = 31; break;
#endif
				default:
					break;
				}
				if (pos != -1)
				{
					mSamplerRegisterMap.insert(std::make_pair(paramName, pos));
				}
			}

			// Get next
			parameter = cgGetNextParameter(parameter);
		}

		
	}
Example #21
0
// check basename for texture, and try to return jpg or png file 
void CheckTexture(const char *baseName, String &textureFileName)
{

	const char *ext = strrchr(baseName,'.');

	// check if jpg exists
	textureFileName=baseName;
	if (!ext) {
		textureFileName+=".jpg";

		if (ExistsFile(textureFileName.c_str()))
			return;
	}


	// check if png exists
	textureFileName=baseName;
	if (ext)  // erase ext 
		textureFileName.erase(textureFileName.size()-strlen(ext),strlen(ext));

	textureFileName+=".png";

	if (ExistsFile(textureFileName.c_str()))
		return;

	// check if tga exists
	textureFileName=baseName;
	if (ext)  // erase ext 
		textureFileName.erase(textureFileName.size()-strlen(ext),strlen(ext));

	textureFileName+=".tga";

	if (ExistsFile(textureFileName.c_str())) {
		// convert tga to png
		String outFileName=baseName;
		if (ext)  // erase ext 
			outFileName.erase(outFileName.size()-strlen(ext),strlen(ext));

		outFileName+=".png";

		// bmp.TGAToPNG(textureFileName.c_str(),outFileName.c_str());
		int width, height, comp;
		unsigned char *data = stbi_load(textureFileName.c_str(), &width, &height, &comp	, 0);
		stbi_write_png(outFileName.c_str(), width, height, comp, data, width*comp);
		stbi_image_free(data);

		textureFileName = outFileName;
		return;
	
	}

	// check if jpg exists
	textureFileName=baseName;
	if (ext)  // erase ext 
		textureFileName.erase(textureFileName.size()-strlen(ext),strlen(ext));

	textureFileName+=".jpg";

	if (ExistsFile(textureFileName.c_str()))
		return;

	printf("Texture file not found:'%s'\n",baseName);

}
Example #22
0
    //-----------------------------------------------------------------------
    void GLSLProgramCommon::extractLayoutQualifiers(void)
    {
        // Format is:
        //      layout(location = 0) attribute vec4 vertex;

        if(mVertexProgram)
        {
            String shaderSource = mVertexProgram->getGLSLProgram()->getSource();
            String::size_type currPos = shaderSource.find("layout");
            while (currPos != String::npos)
            {
                VertexElementSemantic semantic;
                GLint index = 0;

                String::size_type endPos = shaderSource.find(";", currPos);
				if (endPos == String::npos)
				{
					// Problem, missing semicolon, abort
					break;
				}

				String line = shaderSource.substr(currPos, endPos - currPos);

                // Skip over 'layout'
                currPos += 6;

                // Skip until '='
                String::size_type eqPos = line.find("=");
                String::size_type parenPos = line.find(")");

                // Skip past '=' up to a ')' which contains an integer(the position).  This could be a definition, does the preprocessor do replacement?
                String attrLocation = line.substr(eqPos + 1, parenPos - eqPos - 1);
                StringUtil::trim(attrLocation);
                GLint attrib = StringConverter::parseInt(attrLocation);

                // The rest of the line is a standard attribute definition.
                // Erase up to it then split the remainder by spaces.
                line.erase (0, parenPos + 1);
                StringUtil::trim(line);
				StringVector parts = StringUtil::split(line, " ");

                if(parts.size() < 3)
                {
                    // This is a malformed attribute
                    // It should contain 3 parts, i.e. "attribute vec4 vertex"
                    break;
                }

                String attrName = parts[2];

                // Special case for attribute named position
                if(attrName == "position")
                    semantic = getAttributeSemanticEnum("vertex");
                else
                    semantic = getAttributeSemanticEnum(attrName);

                // Find the texture unit index
                String::size_type uvPos = attrName.find("uv");
                if(uvPos != String::npos)
                {
                    String uvIndex = attrName.substr(uvPos + 2, attrName.length() - 2);
                    index = StringConverter::parseInt(uvIndex);
                }

                mCustomAttributesIndexes[semantic-1][index] = attrib;

                currPos = shaderSource.find("layout", currPos);
            }
        }
    }
Example #23
0
  void createParamFile_(ostream& os)
  {
    os << "# comet_version " << getStringOption_("comet_version") << "\n";               //required as first line in the param file
    os << "# Comet MS/MS search engine parameters file.\n";
    os << "# Everything following the '#' symbol is treated as a comment.\n";
    os << "database_name = " << getStringOption_("database") << "\n";
    os << "decoy_search = " << 0 << "\n"; // 0=no (default), 1=concatenated search, 2=separate search
    os << "num_threads = " << getIntOption_("threads") << "\n";  // 0=poll CPU to set num threads; else specify num threads directly (max 64)

    // masses
    map<String,int> precursor_error_units;
    precursor_error_units["amu"] = 0;
    precursor_error_units["mmu"] = 1;
    precursor_error_units["ppm"] = 2;

    map<string,int> isotope_error;
    isotope_error["off"] = 0;
    isotope_error["-1/0/1/2/3"] = 1;
    isotope_error["-8/-4/0/4/8"] = 2;

    os << "peptide_mass_tolerance = " << getDoubleOption_("precursor_mass_tolerance") << "\n";
    os << "peptide_mass_units = " << precursor_error_units[getStringOption_("precursor_error_units")] << "\n";                  // 0=amu, 1=mmu, 2=ppm
    os << "mass_type_parent = " << 1 << "\n";                    // 0=average masses, 1=monoisotopic masses
    os << "mass_type_fragment = " << 1 << "\n";                  // 0=average masses, 1=monoisotopic masses
    os << "precursor_tolerance_type = " << 0 << "\n";            // 0=MH+ (default), 1=precursor m/z; only valid for amu/mmu tolerances
    os << "isotope_error = " << isotope_error[getStringOption_("isotope_error")] << "\n";                      // 0=off, 1=on -1/0/1/2/3 (standard C13 error), 2= -8/-4/0/4/8 (for +4/+8 labeling)

    // search enzyme

    String enzyme_name = getStringOption_("enzyme");
    String enzyme_number = String(ProteaseDB::getInstance()->getEnzyme(enzyme_name)->getCometID());

    map<string,int> num_enzyme_termini;
    num_enzyme_termini["semi"] = 1;
    num_enzyme_termini["fully"] = 2;
    num_enzyme_termini["C-term unspecific"] = 8;
    num_enzyme_termini["N-term unspecific"] = 9;

    os << "search_enzyme_number = " << enzyme_number << "\n";                // choose from list at end of this params file
    os << "num_enzyme_termini = " << num_enzyme_termini[getStringOption_("num_enzyme_termini")] << "\n";                  // 1 (semi-digested), 2 (fully digested, default), 8 C-term unspecific , 9 N-term unspecific
    os << "allowed_missed_cleavage = " << getIntOption_("allowed_missed_cleavages") << "\n";             // maximum value is 5; for enzyme search

    // Up to 9 variable modifications are supported
    // format:  <mass> <residues> <0=variable/else binary> <max_mods_per_peptide> <term_distance> <n/c-term> <required>
    //     e.g. 79.966331 STY 0 3 -1 0 0
    vector<String> variable_modifications_names = getStringList_("variable_modifications");
    vector<ResidueModification> variable_modifications = getModifications_(variable_modifications_names);
    if (variable_modifications.size() > 9)
    {
      throw OpenMS::Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Error: Comet only supports 9 variable modifications. " + String(variable_modifications.size()) + " provided.");
    }

    int max_variable_mods_in_peptide = getIntOption_("max_variable_mods_in_peptide");
    Size var_mod_index = 0;

    // write out user specified modifications
    for (; var_mod_index < variable_modifications.size(); ++var_mod_index)
    {
      const ResidueModification mod = variable_modifications[var_mod_index];
      double mass = mod.getDiffMonoMass();
      String residues = mod.getOrigin();
      //TODO support binary groups, e.g. for SILAC
      int binary_group = 0;
      //TODO support mod-specific limit (default for now is the overall max per peptide)
      int max_current_mod_per_peptide = max_variable_mods_in_peptide;
      //TODO support term-distances?
      int term_distance = -1;
      int nc_term = 0;

      //TODO support agglomeration of Modifications to same AA. Watch out for nc_term value then.
      if (mod.getTermSpecificity() == ResidueModification::C_TERM)
      {
        residues = "c";
        term_distance = 0;
        // Since users need to specify mods that apply to multiple residues/terms separately
        // 3 and -1 should be equal for now.
        nc_term = 3;
      }
      else if (mod.getTermSpecificity() == ResidueModification::N_TERM)
      {
        residues = "n";
        term_distance = 0;
        // Since users need to specify mods that apply to multiple residues/terms separately
        // 2 and -1 should be equal for now.
        nc_term = 2;
      }
      else if (mod.getTermSpecificity() == ResidueModification::PROTEIN_N_TERM) // not yet available
      {
        term_distance = 0;
        nc_term = 0;
      }
      else if (mod.getTermSpecificity() == ResidueModification::PROTEIN_C_TERM) // not yet available
      {
        term_distance = 0;
        nc_term = 1;
      }

      //TODO support required variable mods
      bool required = false;

      os << "variable_mod0" << var_mod_index+1 << " = " << mass << " " << residues << " " << binary_group << " " << max_current_mod_per_peptide << " " << term_distance << " " << nc_term << " " << required << "\n";
    }

    // fill remaining modification slots (if any) in Comet with "no modification"
    for (; var_mod_index < 9; ++var_mod_index)
    {
      os << "variable_mod0" << var_mod_index+1 << " = " << "0.0 X 0 3 -1 0 0" << "\n";
    }

    os << "max_variable_mods_in_peptide = " << getIntOption_("max_variable_mods_in_peptide") << "\n";
    os << "require_variable_mod = " << (int) (getStringOption_("require_variable_mod") == "true") << "\n";

    // fragment ion defaults
    // ion trap ms/ms:  1.0005 tolerance, 0.4 offset (mono masses), theoretical_fragment_ions = 1
    // high res ms/ms:    0.02 tolerance, 0.0 offset (mono masses), theoretical_fragment_ions = 0

    String instrument = getStringOption_("instrument");
    double bin_tol = getDoubleOption_("fragment_bin_tolerance");
    double bin_offset = getDoubleOption_("fragment_bin_offset");
    if (instrument == "low_res" && (bin_tol < 0.9 || bin_offset <= 0.2))
    {
      LOG_WARN << "Fragment bin size or tolerance is quite low for low res instruments." << "\n";
    }
    else if (instrument == "high_res" && (bin_tol > 0.2 || bin_offset > 0.1))
    {
      LOG_WARN << "Fragment bin size or tolerance is quite high for high res instruments." << "\n";
    };

    os << "fragment_bin_tol = " << bin_tol << "\n";               // binning to use on fragment ions
    os << "fragment_bin_offset = " << bin_offset  << "\n";              // offset position to start the binning (0.0 to 1.0)
    os << "theoretical_fragment_ions = " << (int)(instrument == "low_res") << "\n";           // 0=use flanking bin, 1=use M bin only
    os << "use_A_ions = " << (int)(getStringOption_("use_A_ions")=="true") << "\n";
    os << "use_B_ions = " << (int)(getStringOption_("use_B_ions")=="true") << "\n";
    os << "use_C_ions = " << (int)(getStringOption_("use_C_ions")=="true") << "\n";
    os << "use_X_ions = " << (int)(getStringOption_("use_X_ions")=="true") << "\n";
    os << "use_Y_ions = " << (int)(getStringOption_("use_Y_ions")=="true") << "\n";
    os << "use_Z_ions = " << (int)(getStringOption_("use_Z_ions")=="true") << "\n";
    os << "use_NL_ions = " << (int)(getStringOption_("use_NL_ions")=="true") << "\n";                         // 0=no, 1=yes to consider NH3/H2O neutral loss peaks

    // output
    os << "output_sqtstream = " << 0 << "\n";                    // 0=no, 1=yes  write sqt to standard output
    os << "output_sqtfile = " << 0 << "\n";                      // 0=no, 1=yes  write sqt file
    os << "output_txtfile = " << 0 << "\n";                     // 0=no, 1=yes  write tab-delimited txt file
    os << "output_pepxmlfile = " << 1 << "\n";                   // 0=no, 1=yes  write pep.xml file

    os << "output_percolatorfile = " << !getStringOption_("pin_out").empty() << "\n";              // 0=no, 1=yes  write Percolator tab-delimited input file
    os << "output_outfiles = " <<  0 << "\n";                    // 0=no, 1=yes  write .out files
    os << "print_expect_score = " << 1 << "\n";                  // 0=no, 1=yes to replace Sp with expect in out & sqt
    os << "num_output_lines = " << getIntOption_("num_hits") << "\n";                    // num peptide results to show
    os << "show_fragment_ions = " << 0 << "\n";                  // 0=no, 1=yes for out files only
    os << "sample_enzyme_number = " << enzyme_number << "\n";                // Sample enzyme which is possibly different than the one applied to the search.

    // mzXML parameters
    map<string,int> override_charge;
    override_charge["keep any known"] = 0;
    override_charge["ignore known"] = 1;
    override_charge["ignore outside range"] = 2;
    override_charge["keep known search unknown"] = 3;

    int precursor_charge_min(0), precursor_charge_max(0);
    if (!parseRange_(getStringOption_("precursor_charge"), precursor_charge_min, precursor_charge_max))
    {
      LOG_INFO << "precursor_charge range not set. Defaulting to 0:0 (disable charge filtering)." << endl;
    }

    os << "scan_range = " << "0 0" << "\n";                        // start and scan scan range to search; 0 as 1st entry ignores parameter
    os << "precursor_charge = " << precursor_charge_min << " " << precursor_charge_max << "\n";                  // precursor charge range to analyze; does not override any existing charge; 0 as 1st entry ignores parameter
    os << "override_charge = " << override_charge[getStringOption_("override_charge")] << "\n";                     // 0=no, 1=override precursor charge states, 2=ignore precursor charges outside precursor_charge range, 3=see online
    os << "ms_level = " << getIntOption_("ms_level") << "\n";                            // MS level to analyze, valid are levels 2 (default) or 3
    os << "activation_method = " << getStringOption_("activation_method") << "\n";                 // activation method; used if activation method set; allowed ALL, CID, ECD, ETD, PQD, HCD, IRMPD

    // misc parameters
    double digest_mass_range_min(600.0), digest_mass_range_max(5000.0);
    if (!parseRange_(getStringOption_("digest_mass_range"), digest_mass_range_min, digest_mass_range_max))
    {
      LOG_INFO << "digest_mass_range not set. Defaulting to 600.0 5000.0." << endl;
    }

    os << "digest_mass_range = " << digest_mass_range_min << " " << digest_mass_range_max << "\n";        // MH+ peptide mass range to analyze
    os << "num_results = " << 100 << "\n";                       // number of search hits to store internally
    os << "skip_researching = " << 1 << "\n";                    // for '.out' file output only, 0=search everything again (default), 1=don't search if .out exists
    os << "max_fragment_charge = " << getIntOption_("max_fragment_charge") << "\n";                 // set maximum fragment charge state to analyze (allowed max 5)
    os << "max_precursor_charge = " << getIntOption_("max_precursor_charge") << "\n";                // set maximum precursor charge state to analyze (allowed max 9)
    os << "nucleotide_reading_frame = " << 0 << "\n";            // 0=proteinDB, 1-6, 7=forward three, 8=reverse three, 9=all six
    os << "clip_nterm_methionine = " << (int)(getStringOption_("clip_nterm_methionine")=="true") << "\n";              // 0=leave sequences as-is; 1=also consider sequence w/o N-term methionine
    os << "spectrum_batch_size = " << getIntOption_("spectrum_batch_size") << "\n";                 // max. // of spectra to search at a time; 0 to search the entire scan range in one loop
    os << "decoy_prefix = " << "--decoysearch-not-used--" << "\n";                 // decoy entries are denoted by this string which is pre-pended to each protein accession
    os << "output_suffix = " << "" << "\n";                      // add a suffix to output base names i.e. suffix "-C" generates base-C.pep.xml from base.mzXML input
    os << "mass_offsets = " << ListUtils::concatenate(getDoubleList_("mass_offsets"), " ") << "\n"; // one or more mass offsets to search (values subtracted from deconvoluted precursor mass)

    // spectral processing
    map<string,int> remove_precursor_peak;
    remove_precursor_peak["no"] = 0;
    remove_precursor_peak["yes"] = 1;
    remove_precursor_peak["charge_reduced"] = 2;
    remove_precursor_peak["phosphate_loss"] = 3;

    double clear_mz_range_min(0.0), clear_mz_range_max(0.0);
    if (!parseRange_(getStringOption_("clear_mz_range"), clear_mz_range_min, clear_mz_range_max))
    {
      LOG_INFO << "clear_mz_range not set. Defaulting to 0:0 (disable m/z filter)." << endl;
    }

    os << "minimum_peaks = " << getIntOption_("minimum_peaks") << "\n";                      // required minimum number of peaks in spectrum to search (default 10)
    os << "minimum_intensity = " << getDoubleOption_("minimum_intensity") << "\n";                   // minimum intensity value to read in
    os << "remove_precursor_peak = " << remove_precursor_peak[getStringOption_("remove_precursor_peak")] << "\n";               // 0=no, 1=yes, 2=all charge reduced precursor peaks (for ETD)
    os << "remove_precursor_tolerance = " << getDoubleOption_("remove_precursor_tolerance") << "\n";        // +- Da tolerance for precursor removal
    os << "clear_mz_range = " << clear_mz_range_min << " " << clear_mz_range_max << "\n";                // for iTRAQ/TMT type data; will clear out all peaks in the specified m/z range


    // write fixed modifications - if not specified residue parameter is zero
    // Aminoacid:
    //      add_AA.OneletterCode_AA.ThreeLetterCode = xxx
    // Terminus:
    //      add_N/Cterm_peptide = xxx       protein not available yet
    vector<String> fixed_modifications_names = getStringList_("fixed_modifications");
    vector<ResidueModification> fixed_modifications = getModifications_(fixed_modifications_names);
    // Comet sets Carbamidometyl (C) as modification as default even if not specified
    // Therefor there is the need to set it to 0 if not set as flag
    if (fixed_modifications.empty())
    {
      os << "add_C_cysteine = 0.0000" << endl;
    }
    else
    {
      for (vector<ResidueModification>::const_iterator it = fixed_modifications.begin(); it != fixed_modifications.end(); ++it)
      {
        String AA = it->getOrigin();
        if ((AA!="N-term") && (AA!="C-term"))
        {
          const Residue* r = ResidueDB::getInstance()->getResidue(AA);
          String name = r->getName();
          os << "add_" << r->getOneLetterCode() << "_" << name.toLower() << " = " << it->getDiffMonoMass() << endl;
        }
        else
        {
          os << "add_" << AA.erase(1,1) << "_peptide = " << it->getDiffMonoMass() << endl;
        }
      }
    }

    //TODO register cut_before and cut_after in Enzymes.xml plus datastructures to add all our Enzymes with our names instead.
    // COMET_ENZYME_INFO _must_ be at the end of this parameters file
    os << "[COMET_ENZYME_INFO]" << "\n";
    os << "0.  No_enzyme              0      -           -" << "\n";
    os << "1.  Trypsin                1      KR          P" << "\n";
    os << "2.  Trypsin/P              1      KR          -" << "\n";
    os << "3.  Lys_C                  1      K           P" << "\n";
    os << "4.  Lys_N                  0      K           -" << "\n";
    os << "5.  Arg_C                  1      R           P" << "\n";
    os << "6.  Asp_N                  0      D           -" << "\n";
    os << "7.  CNBr                   1      M           -" << "\n";
    os << "8.  Glu_C                  1      DE          P" << "\n";
    os << "9.  PepsinA                1      FL          P" << "\n";
    os << "10. Chymotrypsin           1      FWYL        P" << "\n";
  }
Example #24
0
bool CRhodesModule::ParseCommandLine(LPCTSTR lpCmdLine, HRESULT* pnRetCode ) throw( )
{
	m_nRestarting = 1;
	LPCTSTR lpszToken = lpCmdLine;
	LPCTSTR nextToken;
    getRhoRootPath();

	m_logPort = "";
	m_isRhoConnectPush = false;

	while (lpszToken != NULL)
	{
		// skip leading spaces and double-quote (if present)
	    bool doubleQuote = false;
		while ((*lpszToken != 0) && ((*lpszToken==' ') || ((!doubleQuote) && (*lpszToken=='"')))) {
			if (*lpszToken=='"')
				doubleQuote = true;
			lpszToken++;
		}
		// skip leading spaces and check for leading '/' or '-' of command line option
		bool isCmdLineOpt = false;
		while ((*lpszToken != 0) && ((*lpszToken==' ') || ((!isCmdLineOpt) && ((*lpszToken=='/') || (*lpszToken=='-'))))) {
			if ((*lpszToken=='/') || (*lpszToken=='-'))
				isCmdLineOpt = true;
			lpszToken++;
		}
		// finish command line processing on EOL
		if (*lpszToken == 0) break;

		// if option starts with double-quote, find its end by next double-quote;
		// otherwise the end will be found automatically
		nextToken = doubleQuote ? FindOneOf(lpszToken, _T("\"")) : NULL;

		//parseToken will allocate extra byte at the end of the returned token value
		LPTSTR value = parseToken( lpszToken, &nextToken );

		if (isCmdLineOpt) {
			if (WordCmpI(lpszToken, _T("Restarting"))==0) {
				m_nRestarting = 10;
			}

			if (WordCmpI(lpszToken, _T("rhoconnectpush"))==0) {
				m_isRhoConnectPush = true;
			}

			else if (wcsncmp(lpszToken, _T("log"), 3)==0) 
			{
				if (value) {
					m_logPort = convertToStringA(value);
				}
				else {
					m_logPort = rho::String("11000");
				}
			}

#if defined(APP_BUILD_CAPABILITY_SHARED_RUNTIME)
			else if (wcsnicmp(lpszToken, _T("s"),1)==0)
			{
				if (value) {
					// RhoElements v1.0 compatibility mode
					String strPath = convertToStringA(value);
					rho_wmimpl_set_startpage(strPath.c_str());
				}
			}
			else if (wcsnicmp(lpszToken, _T("c"),1)==0)
			{
				if (value) {
					String strPath = convertToStringA(value);
					if (strPath.substr(0,7).compare("file://")==0)
						strPath.erase(0,7);
					rho_wmimpl_set_configfilepath(strPath.c_str());
				}
			}
#endif // APP_BUILD_CAPABILITY_SHARED_RUNTIME

#if defined(OS_WINDOWS_DESKTOP)
			else if (wcsncmp(lpszToken, _T("http_proxy_url"),14)==0) 
			{
				if (value) {
					m_strHttpProxy = convertToStringA(value);
				}
				else 
					LOG(WARNING) + "invalid value for \"http_proxy_url\" cmd parameter";

			} else if (wcsncmp(lpszToken, _T("approot"),7)==0) 
			{
				if (value) {
					m_strRootPath = convertToStringA(value);
					String_replace(m_strRootPath, '\\', '/');
					if (m_strRootPath.at(m_strRootPath.length()-1)!='/')
						m_strRootPath.append("/");
				}
			} else if (wcsncmp(lpszToken, _T("rhodespath"),10)==0) 
			{
				if (value) {
					m_strRhodesPath = convertToStringA(value);
					String_replace(m_strRhodesPath, '\\', '/');
				}
			} /* else if (wcsncmp(lpszToken, _T("appname"),7)==0) 
			{
				if (value) {
					m_strAppNameW = convertToStringW(value);
				}
			} else if (wcsncmp(lpszToken, _T("debughost"),9)==0) 
			{
				if (value) {
					m_strDebugHost = convertToStringA(value);
				}
			} else if (wcsncmp(lpszToken, _T("debugport"),9)==0) 
			{
				if (value) {
					m_strDebugPort = convertToStringA(value);
				}
			} */
#else
			else if (wcsnicmp(lpszToken, _T("approot"),7)==0)
			{
				if (value) {
					// RhoElements v2.0 Shared Runtime command line parameter
					m_strRootPath = convertToStringA(value);
					if (m_strRootPath.substr(0,7).compare("file://")==0)
						m_strRootPath.erase(0,7);
					String_replace(m_strRootPath, '\\', '/');
					if (m_strRootPath.at(m_strRootPath.length()-1)!='/')
						m_strRootPath.append("/");
					m_strRootPath.append("rho/");
#ifdef APP_BUILD_CAPABILITY_SHARED_RUNTIME
					rho_wmimpl_set_is_version2(m_strRootPath.c_str());
#endif
        		}
			}
#endif
		}
		if (value) free(value);
		lpszToken = nextToken;
	}

	return __super::ParseCommandLine(lpCmdLine, pnRetCode);
}