Example #1
0
	/*=============================================================================
    -- Returns true if the open element (thing in tags "<>" but with a "/") is
	   equivalent to the token.
    =============================================================================*/
	bool HMLFile::AtElementOpen(String element)
	{
		//add the "<>" tags if they aren't already there
        if (element[0] != "<")
            element.Insert("<", 0);
        if (element[element.Size()-1] != ">")
            element.Insert(">", element.Size());

        if (GetToken() == element)
            return true;

		if (mFile.eof())
			return true;

        return false;
	}
Example #2
0
String TForm3::Format(String s)
{
if (s.Trim()=="") {return s;}
int length=LE->Text.Length();
//1 произвести замены
bool replace=false;
for (int i=1; i<SG->RowCount-1&&!replace; i++)
	{
	String r=Replace(s,SG->Cells[0][i],SG->Cells[1][i]);
	if (s!=r)
		{
		replace=true;
		s=r;
		}
	}
if (replace)
	{
	s=Replace(s,".","");
	s=Replace(s,"-","");
	s=Replace(s,",","");
	s=Replace(s,":","");

		//2 форматировать как на образце
		int k=0;
		for (int i=1; i<=length; i++)
			{
			if (LE->Text.SubString(i,1)!="_")
				{
				s.Insert(LE->Text.SubString(i,1),i+k);
				//k++;
				}
			}
	}
return s.SubString(1,length);
}
Example #3
0
/**
*  @brief
*    Gets a AngelScript function declaration
*/
String Script::GetAngelScriptFunctionDeclaration(const String &sFunctionName, const String &sFunctionSignature, bool bCppToAngelScript) const
{
	// Start with the PixelLight function signature (e.g. "void(int,float)")
	String sFunctionDeclaration = sFunctionSignature;

	// Find the index of the "("
	int nIndex = sFunctionDeclaration.IndexOf("(");
	if (nIndex > -1) {

		// [HACK] AngelScript really don't like something like "string MyFunction(string)", it want's "string @MyFunction(const string &)"!
		// I assume that "@" means "AngelScript, take over the control of the given memory". I wasn't able to find the documentation about
		// the AngelScript function declaration syntax, just "scriptstring.cpp" as example.
		if (bCppToAngelScript && sFunctionDeclaration.IndexOf("string") > -1) {
			String sParameters = sFunctionDeclaration.GetSubstring(nIndex);	// Find the parameters part in the string
			sParameters.Replace("string", "const string &");				// Change parameters
			sFunctionDeclaration.Delete(nIndex);							// Remove parameters from original function declaration
			sFunctionDeclaration.Replace("string", "string @");				// Change return
			sFunctionDeclaration += sParameters;							// Construct new function declaration
			nIndex = sFunctionDeclaration.IndexOf("(");						// Update the "(" index
		}

		// Create the AngelScript function declaration (e.g. "void MyFunction(int,float)")
		sFunctionDeclaration.Insert(' ' + sFunctionName, nIndex);
	}

	// Return the AngelScript function declaration (e.g. "void MyFunction(int,float)")
	return sFunctionDeclaration;
}
Example #4
0
static inline void
EscapeAttributeChars(String& aStr)
{
  int32_t offset = 0;
  static const char kCharsToEscape[] = ":;=,\\";
  while ((offset = aStr.FindCharInSet(kCharsToEscape, offset)) != kNotFound) {
    aStr.Insert('\\', offset);
    offset += 2;
  }
}
Example #5
0
    /*=============================================================================
    -- Seeks through the file until it reaches the opening element (thing in tags
       "<>") or the end.
    =============================================================================*/
    bool HMLFile::SeekElementOpen(String element)
    {
        //add the "<>" tags if they aren't already there
        if (element[0] != "<")
            element.Insert("<", 0);
        if (element[element.Size()-1] != ">")
            element.Insert(">", element.Size());

        if (!mFile.is_open())
            return false;

        //seek to the element tag
        while (GetToken() != element.GetStd())
        {
			//return false because the file couldn't seek any further (at end of file)
            if (!Seek())
                return false;
        }


        return true;
    }
Example #6
0
void CommentOutFunction(String& code, const String& signature)
{
    unsigned startPos = code.Find(signature);
    unsigned braceLevel = 0;
    if (startPos == String::NPOS)
        return;
    
    code.Insert(startPos, "/*");
    
    for (unsigned i = startPos + 2 + signature.Length(); i < code.Length(); ++i)
    {
        if (code[i] == '{')
            ++braceLevel;
        else if (code[i] == '}')
        {
            --braceLevel;
            if (braceLevel == 0)
            {
                code.Insert(i + 1, "*/");
                return;
            }
        }
    }
}
Example #7
0
BadaFileStream *BadaFileStream::makeFromPath(const String &path, bool writeMode) {
	File *ioFile = new File();

	String filePath = path;
	if (writeMode && (path[0] != '.' && path[0] != '/')) {
		filePath.Insert(PATH_HOME_X, 0);
	}

	AppLog("Open file %S", filePath.GetPointer());

	result r = ioFile->Construct(filePath, writeMode ? L"w" : L"r", writeMode);
	if (r == E_SUCCESS) {
		return new BadaFileStream(ioFile, writeMode);
	}

	AppLog("Failed to open file");
	delete ioFile;
	return 0;
}