StdStringUtils.cpp File Reference


Detailed Description

Additional functions for std::string.

Useful string functions and emulating some function calls used by MFC CString.

[1]. Microsoft CString MSDN page http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cstring_class_members.asp

Author:
Glenn D. MacGougan (GDM)
Since:
2006-12-20
Date:
2007-01-09
"LICENSE INFORMATION"
Copyright (c) 2007, refer to 'author' doxygen tags
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file StdStringUtils.cpp.

#include <algorithm>
#include "StdStringUtils.h"

Go to the source code of this file.

Namespaces

namespace  StdStringUtils

Functions

void StdStringUtils::SpanExcluding (const std::string &src, const std::string charSet, std::string &dst)
 Extract the string from the source string until one of the characters in charSet is found.
void StdStringUtils::SpanExcluding (const std::string &src, const std::string charSet, std::string &dst, std::string::size_type &pos)
 Extract the string from the source string until one of the characters in charSet is found. Determine the string position of the end of the string extracted. ie. To aid in the start position of the next search.
void StdStringUtils::MakeUpper (std::string &str)
 Conversion to uppercase.
void StdStringUtils::MakeLower (std::string &str)
 Conversion to lowercase.
void StdStringUtils::TrimRight (std::string &str)
 Remove whitespace starting from right edge.
void StdStringUtils::TrimLeft (std::string &str)
 Remove whitespace starting from left side.
void StdStringUtils::TrimLeftAndRight (std::string &str)
 Remove whitespace from the left and right.
bool StdStringUtils::GetDouble (const std::string &src, double &dValue)
 Get a double from the string.
bool StdStringUtils::GetFloat (const std::string &src, float &fValue)
 Get a float from the string.
bool StdStringUtils::GetInt (const std::string &src, int &iValue)
 Get an int from the string.
bool StdStringUtils::GetUnsignedInt (const std::string &src, unsigned &uiValue)
 Get an unsigned from the string.
bool StdStringUtils::ExtractField (const std::string &str, const unsigned index, const char delimiter, std::string &field)
 Extract a substring from a string delimited by a specific delimiter using a 0-based index.
bool StdStringUtils::ExtractFieldInplace (std::string &str, const char delimiter, std::string &field)
 Extract a substring from a string delimited by a specific delimiter and alter the original string so that the substring and delimiter are removed. e.g.
void StdStringUtils::GetBaseName (const std::string str, std::string &BaseName)
 This function assumes the string is a filename like "c:\folder\data.gps". BaseName == "c:\folder\data", is the extracted string.
void StdStringUtils::GetDirectoryOfThisStringPath (const std::string str, std::string &Directory)
 Assuming this string is a path. Directory is set to the folder containing the file. e.g. For: "c:\folder\subfolder\subsubfolder\data.txt", "c:\folder\subfolder\subsubfolder" is extracted.
void StdStringUtils::GetFileNameFromThisStringPath (const std::string str, std::string &FileName)
 Assuming this string is a path. FileName is set (without the file path). e.g. For: "c:\folder\subfolder\subsubfolder\data.txt", "data.txt" is extracted.