コード例 #1
0
Utf8String ExtractFileName(const Utf8String fileName)
{
		Utf8String temp = fileName;
		int Qpos = temp.find_last_of('?');
		if(Qpos>=0) temp = temp.substr(0, Qpos-1);
		int i,len = temp.length();
		for(i=len-1; i>=0; i--)
		{
			if(temp[i] == '\\' || temp[i]=='/')
				break;
		}
		return temp.substr(i+1);
}
コード例 #2
0
const Utf8String ExtractFileNameNoExt(const Utf8String& fileName)
{
	Utf8String result = ExtractFileName(fileName);
	int Qpos = result.find_last_of('.');
	if(Qpos>=0) result = result.substr(0, Qpos);
	return result;
}
コード例 #3
0
const Utf8String ExtractFilePath(const Utf8String& fileName)
{
	int i, len = fileName.length();
	for(i = len-1; i >= 0; i--)
	{
		if(fileName[i] == '\\' || fileName[i]=='/')
		{
			return fileName.substr(0, i+1);
		}
			
	}
	return "";
}
コード例 #4
0
Utf8String ExtractFileExt(const Utf8String fileName)
{
	int nLen = fileName.length();

	Utf8String result;
	for( int i=nLen-1; i>=0; i-- )
	{
		if(fileName[i] == '.')
		{
			result = fileName.substr(i + 1);
			break;
		}
		else if(fileName[i] == '\\' || fileName[i] == '/') break;
	}
	return result;
}
コード例 #5
0
ファイル: XMLWriter.cpp プロジェクト: Microsoft/pal
/*
**==============================================================================
**
**  Starting with this element, build the output string that represents the entire
**  tree from this point down, building on the passed in string.  In other words,
**  the tree is traversed, and each element has its own save() method called.
**
**==============================================================================
*/
void CXElement::Save(Utf8String& sOut, bool bAddIndentation, Utf8String& sIndentation)
{
    // Output our start tag.
    if (bAddIndentation)
    {
        sOut += sIndentation;
    }

    sOut += open_bracket;
    sOut += m_sName;

    // Output all the attributes and close the start tag.
    for (size_t j = m_listAttribute.size();  j > 0;  j--)
    {
        sOut += u8_space + m_listAttribute[j - 1]->m_sName + equals_with_quote;
        PutText(sOut, m_listAttribute[j - 1]->m_sValue);
        sOut += ending_quote;
    }

    if (m_sName[0] != single_question) // XML_INSTRUCTION
    {
        // If this was an empty tag (just the name and attributes), and there were no children
        // then just close the tag.
        if (m_sText.Empty() && m_listChild.empty())
        {
            sOut += close_bracket_with_term;

            if (m_LineSeparatorsOn)
            {
                sOut += crlf;
            }

            return;
        }
        else
        {
            sOut += close_bracket;
        }
    }
    else
    {
        sOut += close_bracket_with_question;
    }

    if (!m_listChild.empty() && m_LineSeparatorsOn)
    {
        sOut += crlf;
    }

    // Output the text.
    // *** DO NOT put a line separator at the end of this data, or add indentation to the front.
    //     If you do so, and the data happens to be string data, you will be adding an
    //     extra \n\r to the output that will not be parsed out on input.  Changing the
    //     data is generally considered bad practice.
    if (!m_sText.Empty())
    {
        PutText (sOut, m_sText);
    }

    // Output all the child elements.
    std::vector<pCXElement>::iterator i;
    for (i = m_listChild.begin();  i != m_listChild.end();  i++)
    {
        pCXElement singleElement = *i;

        // Call the child element's save() method.
        sIndentation += four_spaces;
        singleElement->Save(sOut, bAddIndentation, sIndentation);
        sIndentation = sIndentation.substr(0, sIndentation.size() - 4);
    }

    if (m_sName[0] != single_question) // XML_INSTRUCTION
    {
        if (m_sText.Empty() && bAddIndentation)
        {
            sOut += sIndentation;
        }

        // Output the end tag.
        sOut += open_with_slash + m_sName + close_bracket;
    }

    // And close us up
    if (m_LineSeparatorsOn)
    {
        sOut += crlf;
    }
}