bool getNthToken (const String & str, const size_t n, size_t & pos, size_t & endpos, String & token, const unicode_char_t * sepChars)
	{
		size_t desired_first_nonspace = 0;
		size_t space = 0;

		//check for trivial case
		if(n == 0)
			desired_first_nonspace = pos;
		else
		{
			for (size_t i = 0; i < n; ++i)
			{
				//find the first whitespace character
				space = str.find_first_of ( sepChars, pos );
				if (space == std::string::npos)
					return false;
				//now find the next non-whitespace character after it
				desired_first_nonspace = str.find_first_not_of( sepChars, space );
				if (desired_first_nonspace == std::string::npos)
					return false;
				pos = desired_first_nonspace;
			}
		}
		//find the end of the token
		const size_t first_space    = str.find_first_of   (sepChars, desired_first_nonspace );
		//now get that token
		if (first_space != std::string::npos)
			token = str.substr (desired_first_nonspace, first_space - desired_first_nonspace);
		else
			token = str.substr (desired_first_nonspace);

		endpos = desired_first_nonspace;

		return true;
	}
Example #2
0
// analyse file name
std::vector<std::size_t> analyse_filename(const String &filename)
{
	std::vector<std::size_t> exercise;
	auto end = filename.find_last_of(TEXT("_."));
	for (auto beg = filename.find_first_of(TEXT("_.")), next = beg;
	    beg != end && beg != filename.size() - 1;
	    beg = next) {
		next = filename.find_first_of(TEXT("_."), beg + 1);
		if (next == String::npos)
			break;
		if(next - beg == 3) {
		#ifndef UNICODE
			if (std::isdigit(filename[beg + 1]) && std::isdigit(filename[beg + 2])) {
		#else
			if (std::iswdigit(filename[beg + 1]) && std::iswdigit(filename[beg + 2])) {
		#endif
				exercise.push_back(stoi(filename.substr(beg + 1, beg + 2)));
			}
		}
	}
	return exercise;
}
// format the file name vector in terms of markdown format as below:
// [file1.cpp](file1.cpp) | [file2.cpp](file2.cpp)
String format(const std::vector<String> &files)
{
	String reval;
	if (files.empty())
		return reval;
	for (auto beg = files.begin(); beg != files.end(); ++beg) {
		reval += wrap(*beg, WRAPPER::SQUARE) + wrap(*beg, WRAPPER::PARENTHESES) + TEXT(" | ");
	}
	return reval.substr(0, reval.size() - 3);
}
Example #3
0
void Wikidiff2::printText(const String & input)
{
	size_t start = 0;
	size_t end = input.find_first_of("<>&");
	while (end != String::npos) {
		if (end > start) {
			result.append(input, start, end - start);
		}
		switch (input[end]) {
			case '<':
				result.append("&lt;");
				break;
			case '>':
				result.append("&gt;");
				break;
			default /*case '&'*/:
				result.append("&amp;");
		}
		start = end + 1;
		end = input.find_first_of("<>&", start);
	}
	// Append the rest of the string after the last special character
	if (start < input.size()) {
		result.append(input, start, input.size() - start);
	}
}
Example #4
0
void Console::WriteToOutput(String output)
{
    // convert tabs first
    size_t tabIndex = output.find_first_of('\t');
    while (tabIndex != std::string::npos)
    {
        int numSpaces = _tabWidth - (tabIndex % _tabWidth);
        String replacement = "";
        for(int i=0; i < numSpaces; i++)
        {
            replacement += " ";
        }
        output = output.substr(0, tabIndex) + replacement + output.substr(tabIndex + 1, output.size() - 1);
        tabIndex = output.find_first_of('\t');
    }


    _unsplitBuffer += output;
    _buffer = SplitString(_unsplitBuffer, "\n", false);

    float largest = 0.0f;
    StringList::iterator it = _buffer.begin();
    Vector2 extents = Vector2::Zero;
    while(it != _buffer.end())
    {
        extents = GetTextExtents((*it), "ConsoleSmall");
        if (extents.Y > largest)
        {
            largest = extents.Y;
        }

        it++;
    }
    _lineHeight = largest;
}
Example #5
0
void * ConfigImporter::getLastWengoUser(const std::string & configUserFile, int version) {
	std::ifstream fileStream;
	String lastLine;

	last_user_t * lastUser = new last_user_t();
	fileStream.open(configUserFile.c_str());
	if (!fileStream) {
		LOG_ERROR("cannot open the file: " + configUserFile);
		return NULL;
	}

	std::getline(fileStream, lastLine);

	while (!lastLine.empty()) {
		lastLine = lastLine.trim();

		if (!strncmp(lastLine.c_str(), "<login>", 7)) {
			int pos1, pos2;
			if (version == CONFIG_VERSION2) {
				pos1 = lastLine.find_first_of('>');
				pos2 = lastLine.find_last_of('<');
			} else {
				pos2 = lastLine.find_first_of(']');
				pos1 = lastLine.find_last_of('[');
			}

			lastUser->login = ((String)lastLine.substr(pos1 + 1, pos2 - (pos1 + 1))).trim();
		}
		else if (!strncmp(lastLine.c_str(), "<password>", 10)) {
			int pos1, pos2;
			if (version == CONFIG_VERSION2) {
				pos1 = lastLine.find_first_of('>');
				pos2 = lastLine.find_last_of('<');
			} else {
				pos2 = lastLine.find_first_of(']');
				pos1 = lastLine.find_last_of('[');
			}

			lastUser->password = ((String) lastLine.substr(pos1 + 1, pos2 - (pos1 + 1))).trim();
		}
		else if (!strncmp(lastLine.c_str(), "<autoLogin>", 11)) {
			int pos1 = lastLine.find_first_of('>');
			int pos2 = lastLine.find_last_of('<');
			string resp = ((String) lastLine.substr(pos1 + 1, pos2 - (pos1 + 1))).trim();

			if (resp == (version == CONFIG_VERSION2 ? "1" : "true")) {
				lastUser->auto_login = true;
			} else {
				lastUser->auto_login = false;
			}
		}

		std::getline(fileStream, lastLine);
	}

	return lastUser;
}
inline String replace_slashes(String value, char const* lookfor = "\\",
    char replace_with = '/')
{
    typename String::size_type p = value.find_first_of(lookfor);
    while (p != value.npos) {
        value[p] = replace_with;
        p = value.find_first_of(lookfor, p+1);
    }
    return value;
}
Example #7
0
void eraseWhiteSpaces( String& str )
{
    static const String aSpaceCharacters( " \t\n" );

    String::size_type p( str.find_first_of( aSpaceCharacters ) );

    while( p != String::npos )
    {
        str.erase( p, 1 );
        p = str.find_first_of( aSpaceCharacters, p );
    }
}
Example #8
0
 /*
   ('a', 0) => 'a'
   ('a', 1) => 'a'
   ('a/b', 0) => 'a'
   ('a/b', 1) => 'b'
 */
 String ExtractMergedValue(const String& val) const
 {
   const String::size_type pos = val.find_first_of('/');
   if (pos != String::npos)
   {
     Require(String::npos == val.find_first_of('/', pos + 1));
     return Index == 0 ? val.substr(0, pos) : val.substr(pos + 1);
   }
   else
   {
     return val;
   }
 }
Example #9
0
//  List
void CGui::updReplaysList()
{
	if (!rplList)  return;
	//Ogre::Timer ti;

	rplList->removeAllItems();

	strlist li;
	PATHMANAGER::DirList(GetRplListDir(), li, "rpl");
	
	for (strlist::iterator i = li.begin(); i != li.end(); ++i)
	if (StringUtil::endsWith(*i, ".rpl"))
	{
		String s = *i;  s = StringUtil::replaceAll(s,".rpl","");
		String slow = s;  StringUtil::toLowerCase(slow);
		if (sRplFind == "" || strstr(slow.c_str(), sRplFind.c_str()) != 0)
		if (pSet->rpl_listview != 1 || StringUtil::startsWith(s,pSet->game.track, false))
		{
			size_type f = s.find_first_of("_-0123456789");
			string ss;
			if (f != string::npos)  ss = s.substr(0,f);
			else  ss = s.substr(0,1);  //gcom->scnClr[gcom->scnN[]];
			rplList->addItem(gcom->GetSceneryColor(ss) + s);
		}
	}
	//LogO(String("::: Time ReplaysList: ") + fToStr(ti.getMilliseconds(),0,3) + " ms");
}
  void Configuration::splitString(String &input, StringList &output, const String &delimiters = " ", const bool trimEmpty = false) const
  {
    if (delimiters.empty())
      throw IllegalArgumentException("Cannot split using empty set of delimiters");

    String::size_type offset = 0;
    while (true)
    {
      String::size_type pos = input.find_first_of(delimiters, offset);
      if (pos == String::npos)
      {
        pos = input.length();

        if (pos != offset || !trimEmpty)
          output.push_back(input.substr(offset));
        break;
      }
      else
      {
        if (pos != offset || !trimEmpty) {
          ASSERT(pos >= offset);
          output.push_back(input.substr(offset, pos - offset));
        }
        offset = pos + 1;
      }
    }
  }
Example #11
0
void SCsTranslator::processSentenceLevel1(pANTLR3_BASE_TREE node)
{
    unsigned int nodesCount = node->getChildCount(node);
    assert(nodesCount == 3);

    pANTLR3_BASE_TREE node_obj = (pANTLR3_BASE_TREE)node->getChild(node, 0);
    pANTLR3_BASE_TREE node_pred = (pANTLR3_BASE_TREE)node->getChild(node, 1);
    pANTLR3_BASE_TREE node_subj = (pANTLR3_BASE_TREE)node->getChild(node, 2);

    pANTLR3_COMMON_TOKEN tok_pred = node_pred->getToken(node_pred);

    if (tok_pred->type != ID_SYSTEM)
    {
        THROW_EXCEPT(Exception::ERR_PARSE,
                     String("Invalid predicate '") + ((const char*) node_pred->getText(node_pred)->chars) + "' in simple sentence",
                     mParams.fileName,
                     tok_pred->getLine(tok_pred));
    }

    sElement *el_obj = parseElementTree(node_obj);
    sElement *el_subj = parseElementTree(node_subj);

    // determine arc type
    sc_type type = sc_type_edge_common;
    String pred = GET_NODE_TEXT(node_pred);
    size_t n = pred.find_first_of("#");
    if (n != pred.npos)
        type = _getArcPreffixType(pred.substr(0, n));

    _addEdge(el_obj, el_subj, type, false, pred);
}
Example #12
0
bool ConfigImporter::classicXMLParser(const string & xmlFile, void *structVcard) {
	vcard_t *mVcard = (vcard_t *) structVcard;
	std::ifstream fileStream;
	String lastLine;

	mVcard->blocked = false;

	fileStream.open(xmlFile.c_str());
	if (!fileStream) {
		LOG_ERROR("cannot open the file: " + xmlFile);
		return false;
	}

	std::getline(fileStream, lastLine);

	while (!lastLine.empty()) {
		lastLine = lastLine.trim();

		if (!strncmp(lastLine.c_str(), "<blocked>", 9)) {
			int pos1 = lastLine.find_first_of('>');
			int pos2 = lastLine.find_last_of('<');
			string resp = ((String)lastLine.substr(pos1 + 1, pos2 - (pos1 + 1))).trim();

			if (resp == "true") {
				mVcard->blocked = true;
			}
		}

		std::getline(fileStream, lastLine);
	}

	return true;
}
Example #13
0
// script_english_number_*
String do_english_num(String input, String(*fun)(int)) {
	if (is_substr(input, 0, _("<param-"))) {
		// a keyword parameter, of the form "<param->123</param->"
		size_t start = skip_tag(input, 0);
		if (start != String::npos) {
			size_t end = input.find_first_of(_('<'), start);
			if (end != String::npos) {
				String is = input.substr(start, end - start);
				long i = 0;
				if (is.ToLong(&i)) {
					if (i == 1) {
						return _("<hint-1>") + substr_replace(input, start, end, fun(i));
					} else {
						return _("<hint-2>") + substr_replace(input, start, end, fun(i));
					}
				}
			}
		}
		return _("<hint-2>") + input;
	} else {
		long i = 0;
		if (input.ToLong(&i)) {
			return fun(i);
		}
		return input;
	}
}
Example #14
0
bool DeleteFiles(String filenames)
{
	// no wildcards in the filename; simply delete the file
	if (filenames.find_first_of(TEXT("*?")) == String::npos)
		return DeleteFile(filenames.c_str()) != 0;

	WIN32_FIND_DATA fd;
    HANDLE hFind = FindFirstFile(filenames.c_str(), &fd);
    if (hFind == INVALID_HANDLE_VALUE)
        return false;

	TCHAR* pDir = new TCHAR[filenames.length() + 1];
	_tcscpy(pDir, filenames.c_str());
	PathRemoveFileSpec(pDir);
	size_t idx = _tcslen(pDir);
	pDir[idx] = PATH_SEPARATOR;
	pDir[idx + 1] = TEXT('\0');
    
	do
    {
		String filename(pDir);
		filename.append(fd.cFileName);
        if (!DeleteFile(filename.c_str()))
		{
			FindClose(hFind);
			return false;
		}
	} while (FindNextFile(hFind, &fd));

	FindClose(hFind);
	return true;
}
Example #15
0
//-----------------------------------------------------------------------
std::vector<String> StringUtil::split(const String& str, const String& delims, unsigned int maxSplits) {
  // static unsigned dl;
  std::vector<String> ret;
  unsigned int numSplits = 0;

  // Use STL methods
  size_t start, pos;
  start = 0;
  do {
    pos = str.find_first_of(delims, start);
    if (pos == start) {
      // Do nothing
      start = pos + 1;
    } else if (pos == String::npos || (maxSplits && numSplits == maxSplits)) {
      // Copy the rest of the string
      ret.push_back( str.substr(start) );
    } else {
      // Copy up to delimiter
      ret.push_back( str.substr(start, pos - start) );
      start = pos + 1;
    }
    // parse up to next real data
    start = str.find_first_not_of(delims, start);
    ++numSplits;

  } while (pos != String::npos);



  return ret;
}
Example #16
0
    //-----------------------------------------------------------------------
    StringVector StringUtil::split( const String& str, const String& delims, unsigned int maxSplits, bool preserveDelims)
    {
        StringVector ret;
        // Pre-allocate some space for performance
        ret.reserve(maxSplits ? maxSplits+1 : 10);    // 10 is guessed capacity for most case

        unsigned int numSplits = 0;

        // Use STL methods 
        size_t start, pos;
        start = 0;
        do 
        {
            pos = str.find_first_of(delims, start);
            if (pos == start)
            {
                // Do nothing
                start = pos + 1;
            }
            else if (pos == String::npos || (maxSplits && numSplits == maxSplits))
            {
                // Copy the rest of the string
                ret.push_back( str.substr(start) );
                break;
            }
            else
            {
                // Copy up to delimiter
                ret.push_back( str.substr(start, pos - start) );

                if(preserveDelims)
                {
                    // Sometimes there could be more than one delimiter in a row.
                    // Loop until we don't find any more delims
                    size_t delimStart = pos, delimPos;
                    delimPos = str.find_first_not_of(delims, delimStart);
                    if (delimPos == String::npos)
                    {
                        // Copy the rest of the string
                        ret.push_back( str.substr(delimStart) );
                    }
                    else
                    {
                        ret.push_back( str.substr(delimStart, delimPos - delimStart) );
                    }
                }

                start = pos + 1;
            }
            // parse up to next real data
            start = str.find_first_not_of(delims, start);
            ++numSplits;

        } while (pos != String::npos);



        return ret;
    }
Example #17
0
/*************************************************************************
    Return the number of lines the given text would be formatted to.
*************************************************************************/
size_t Font::getFormattedLineCount(const String& text, const Rect& format_area, TextFormatting fmt, float x_scale)
{
    // handle simple non-wrapped cases.
    if ((fmt == LeftAligned) || (fmt == Centred) || (fmt == RightAligned) || (fmt == Justified))
    {
        return std::count(text.begin(), text.end(), static_cast<utf8>('\n')) + 1;
    }

    // handle wraping cases
    size_t lineStart = 0, lineEnd = 0;
    String	sourceLine;

    float	wrap_width = format_area.getWidth();
    String  whitespace = TextUtils::DefaultWhitespace;
    String	thisLine, thisWord;
    size_t	line_count = 0, currpos = 0;

    while (lineEnd < text.length())
    {
        if ((lineEnd = text.find_first_of('\n', lineStart)) == String::npos)
        {
            lineEnd = text.length();
        }

        sourceLine = text.substr(lineStart, lineEnd - lineStart);
        lineStart = lineEnd + 1;

        // get first word.
        currpos = getNextWord(sourceLine, 0, thisLine);

        // while there are words left in the string...
        while (String::npos != sourceLine.find_first_not_of(whitespace, currpos))
        {
            // get next word of the string...
            currpos += getNextWord(sourceLine, currpos, thisWord);

            // if the new word would make the string too long
            if ((getTextExtent(thisLine, x_scale) + getTextExtent(thisWord, x_scale)) > wrap_width)
            {
                // too long, so that's another line of text
                line_count++;

                // remove whitespace from next word - it will form start of next line
                thisWord = thisWord.substr(thisWord.find_first_not_of(whitespace));

                // reset for a new line.
                thisLine.clear();
            }

            // add the next word to the line
            thisLine += thisWord;
        }

        // plus one for final line
        line_count++;
    }

    return line_count;
}
Example #18
0
static String get_param_portion (const String &str)
{
    String::size_type begin = str.find_first_of (" \t\n\v=");

    if (begin == String::npos) return str;

    return str.substr (0, begin);
}
Example #19
0
static String get_value_portion (const String &str)
{
    String::size_type begin = str.find_first_of ("=");

    if (begin == String::npos || (begin + 1) == str.length ()) return String ("");

    return trim_blank (str.substr (begin + 1, String::npos));
}
Example #20
0
 String NextSubstring(const String& str, u32& pos, const String& find = NEWLINE)
 {
   u32 end = str.find_first_of(find, pos);
   if(end == std::string::npos)
     end = str.size() - 1;
   String ret = str.substr(pos, end - pos);
   pos = end + 1;
   return ret;
 }
Example #21
0
/// Format the input variable based on a printf like style specification
String format_input(const String& format, const ScriptValue& input) {
	// determine type of input
	ScriptType type = input.type();
	if (type == SCRIPT_DATETIME) {
		return input.toDateTime().Format(format.c_str());
	} else {
		// determine type expected by format string
		String fmt = _("%") + replace_all(format, _("%"), _(""));
		if (format.find_first_of(_("DdIiOoXx")) != String::npos) {
			return String::Format(fmt, input.toInt());
		} else if (format.find_first_of(_("EeFfGg")) != String::npos) {
			return String::Format(fmt, input.toDouble());
		} else if (format.find_first_of(_("Ss")) != String::npos) {
			return format_string(fmt, input.toString());
		} else {
			throw ScriptError(_ERROR_1_("unsupported format", format));
		}
	}
}
Example #22
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);
    }
}
Example #23
0
 void StringTools::RemoveDuplicateWhitespaces(String& Source)
 {
     for( size_t CurrIndex = Source.find_first_of("  ") ; CurrIndex != String::npos ; CurrIndex = Source.find_first_of("  ",CurrIndex) )
     {
         size_t EndIndex = CurrIndex;
         while( Source[EndIndex] == ' ' ) EndIndex++;
         Source.replace(CurrIndex,EndIndex-CurrIndex," ");
         CurrIndex++;
     }
 }
Example #24
0
/*************************************************************************
    Return the horizontal pixel extent given text would be formatted to.
*************************************************************************/
float Font::getFormattedTextExtent(const String& text, const Rect& format_area, TextFormatting fmt, float x_scale)
{
    float lineWidth;
    float widest = 0;

    size_t lineStart = 0, lineEnd = 0;
    String	currLine;

    while (lineEnd < text.length())
    {
        if ((lineEnd = text.find_first_of('\n', lineStart)) == String::npos)
        {
            lineEnd = text.length();
        }

        currLine = text.substr(lineStart, lineEnd - lineStart);
        lineStart = lineEnd + 1;	// +1 to skip \n char

        switch(fmt)
        {
        case Centred:
        case RightAligned:
        case LeftAligned:
            lineWidth = getTextExtent(currLine, x_scale);
            break;

        case Justified:
            // usually we use the width of the rect but we have to ensure the current line is not wider than that
            lineWidth = ceguimax(format_area.getWidth(), getTextExtent(currLine, x_scale));
            break;

        case WordWrapLeftAligned:
        case WordWrapRightAligned:
        case WordWrapCentred:
            lineWidth = getWrappedTextExtent(currLine, format_area.getWidth(), x_scale);
            break;

        case WordWrapJustified:
            // same as above
            lineWidth = ceguimax(format_area.getWidth(), getWrappedTextExtent(currLine, format_area.getWidth(), x_scale));
            break;

        default:
            throw InvalidRequestException("Font::getFormattedTextExtent - Unknown or unsupported TextFormatting value specified.");
        }

        if (lineWidth > widest)
        {
            widest = lineWidth;
        }

    }

    return widest;
}
Example #25
0
//-----------------------------------------------------------------------------
// TemplateFileParsor::BuildDataFragments
//-----------------------------------------------------------------------------
bool TemplateFileParsor::BuildDataFragments(TemplateToken *pToken, const String &strData)
{
  String strToFragment = strData;
  bool bVarDetected = false;

  while( strToFragment.size() > 0 )
  {
    // Search for a variable
    uint uiFirstPos = strToFragment.find("$(");
    if( String::npos != uiFirstPos )
    {
      // Search for matching ')'. Take care of nested variables
      uint uiMatchPos = strToFragment.find_first_of(')', uiFirstPos + 2);

      if( String::npos != uiMatchPos )
      {
        // New fragment
        if( uiFirstPos > 0 )
        {
          DataFragment fragText(DataFragment::TEXT, strToFragment.substr(0, uiFirstPos));
          pToken->lstDataFragments.push_back(fragText);
        }

        // Delete up to '$(' characters
        strToFragment.erase(0, uiFirstPos + 2);

        // Extract variable content
        DataFragment fragVar(DataFragment::VARIABLE, strToFragment.substr(0, uiMatchPos - uiFirstPos - 2));
        pToken->lstDataFragments.push_back(fragVar);

        // Delete up to matching end parenthesis
        strToFragment.erase(0, uiMatchPos - uiFirstPos - 1);

        bVarDetected = true;
      }
      else
      {
        // Missing close bracket
        // Copying up to the end of template string
        DataFragment fragText(DataFragment::TEXT, strToFragment);
        pToken->lstDataFragments.push_back(fragText);
        strToFragment.erase();
      }
    }
    else
    {
      // Copying up to the end of template string
      DataFragment fragText(DataFragment::TEXT, strToFragment);
      pToken->lstDataFragments.push_back(fragText);
      strToFragment.erase();
    }
  }
  return bVarDetected;
}
Example #26
0
String quoteIfNeeded(const String& str, bool forceQuote)
{
  static String specialChars(" \"\\'");
  for (unsigned i = 0; !forceQuote && i < str.length(); i++)
    forceQuote |= (specialChars.find_first_of(str[i]) != string::npos);

  if (forceQuote)
    return "\"" + addEscapes(str, "\"") + "\"";
  else
    return str;
}
Example #27
0
	static void PrintLongDescription(std::ostream& out, const String& description)
	{
		uint start = 0;
		uint end = 0;
		uint offset = 0;

		do
		{
			// Jump to the next separator
			offset = description.find_first_of(" .\r\n\t", offset);

			// No separator, aborting
			if (String::npos == offset)
				break;

			if (offset - start < LengthLimit)
			{
				if ('\n' == description.at(offset))
				{
					out.write(description.c_str() + start, (std::streamsize)(offset - start));
					out << '\n';
					if (Decal)
						out.write(YUNI_GETOPT_HELPUSAGE_30CHAR, 30);

					start = offset + 1;
					end = offset + 1;
				}
				else
					end = offset;
			}
			else
			{
				if (0 == end)
					end = offset;

				out.write(description.c_str() + start, (std::streamsize)(end - start));
				out << '\n';

				if (Decal)
					out.write(YUNI_GETOPT_HELPUSAGE_30CHAR, 30);

				start = end + 1;
				end = offset + 1;
			}

			++offset;
		}
		while (true);

		// Display the remaining piece of string
		if (start < description.size())
			out << (description.c_str() + start);
	}
        StringList AbstractFileManager::pathComponents(const String& path) {
            StringList components;
            if (path.empty()) return components;
            
            size_t pos = path.find_first_of(pathSeparator(), 0);
            if (pos != String::npos) {
                if (pos > 0)
                    components.push_back(path.substr(0, pos));
                size_t lastPos = pos;
                while ((pos = path.find_first_of(pathSeparator(), lastPos + 1)) != String::npos) {
                    components.push_back(path.substr(lastPos + 1, pos - lastPos - 1));
                    lastPos = pos;
                }
                if (lastPos < path.length() - 1)
                    components.push_back(path.substr(lastPos + 1));
            } else {
                components.push_back(path);
            }

            return components;
        }
//----------------------------------------------------------------------------//
void BasicRenderedStringParser::processControlString(RenderedString& rs,
                                                     const String& ctrl_str)
{
    // All our default strings are of the form <var> = '<val>'
    // so let's get the variables using '=' as delimiter:
    size_t findPos = ctrl_str.find_first_of('=');

    
    if(findPos == String::npos)
    {
        Logger::getSingleton().logEvent(
            "BasicRenderedStringParser::processControlString: invalid "
            "control string declared (format must be <var> = '<val>'): "
            "'" + ctrl_str + "'.  Ignoring!");
        return;
    }

    String variable = ctrl_str.substr(0, findPos);
    String value = ctrl_str.substr(findPos + 1); 

    // We were able to split the variable and value, let's see if we get a
    // valid value:
    bool correctValueFormat = true;
    if ( (value.front() != '\'') || (value.back() != '\'' ) ||
            ( value.length() < 3 ) )
        correctValueFormat = false;
    else
    {
        value.pop_back();
        value.erase(0, 1);
    }

    // look up handler function
    TagHandlerMap::iterator i = d_tagHandlers.find(variable);
    // dispatch handler, or log error
    if (i != d_tagHandlers.end())
    {
        if(correctValueFormat)
        {
            (this->*(*i).second)(rs, value);
        }
        else
            // Otherwise, since the handler was found, we are sure that the
            // second variable couldn't be read, meaning it was empty. We will supply
            // and empty string
            (this->*(*i).second)(rs, "");
    }
    else
        Logger::getSingleton().logEvent(
            "BasicRenderedStringParser::processControlString:  unknown "
            "control variable in string: '" + value + "'.  Ignoring!");
}
String
MSWindowsClipboardHTMLConverter::findArg(
                const String& data, const String& name) const
{
    String::size_type i = data.find(name);
    if (i == String::npos) {
        return String();
    }
    i = data.find_first_of(":\r\n", i);
    if (i == String::npos || data[i] != ':') {
        return String();
    }
    i = data.find_first_of("0123456789\r\n", i + 1);
    if (i == String::npos || data[i] == '\r' || data[i] == '\n') {
        return String();
    }
    String::size_type j = data.find_first_not_of("0123456789", i);
    if (j == String::npos) {
        j = data.size();
    }
    return data.substr(i, j - i);
}