Changeset View
Changeset View
Standalone View
Standalone View
tools/lldb-mi/MIUtilString.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
// Throws: None. | // Throws: None. | ||||
//-- | //-- | ||||
CMIUtilString::CMIUtilString(const char *vpData, size_t nLen) | CMIUtilString::CMIUtilString(const char *vpData, size_t nLen) | ||||
: std::string(vpData, nLen) | : std::string(vpData, nLen) | ||||
{ | { | ||||
} | } | ||||
//++ ------------------------------------------------------------------------------------ | //++ ------------------------------------------------------------------------------------ | ||||
// Details: CMIUtilString constructor. | |||||
// Type: Method. | |||||
// Args: vpStr - Text data. | |||||
// Return: None. | |||||
// Throws: None. | |||||
//-- | |||||
CMIUtilString::CMIUtilString(const std::string& vrStr) | |||||
: std::string(vrStr) | |||||
{ | |||||
} | |||||
//++ ------------------------------------------------------------------------------------ | |||||
// Details: CMIUtilString assignment operator. | // Details: CMIUtilString assignment operator. | ||||
// Type: Method. | // Type: Method. | ||||
// Args: vpRhs - Pointer to UTF8 text data. | // Args: vpRhs - Pointer to UTF8 text data. | ||||
// Return: CMIUtilString & - *this string. | // Return: CMIUtilString & - *this string. | ||||
// Throws: None. | // Throws: None. | ||||
//-- | //-- | ||||
CMIUtilString &CMIUtilString::operator=(const char *vpRhs) | CMIUtilString &CMIUtilString::operator=(const char *vpRhs) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | do | ||||
// Find next occurrence of the delimiter after section | // Find next occurrence of the delimiter after section | ||||
size_t nNextDelimiterPos(FindFirst(vDelimiter, nSectionPos)); | size_t nNextDelimiterPos(FindFirst(vDelimiter, nSectionPos)); | ||||
if (nNextDelimiterPos == std::string::npos) | if (nNextDelimiterPos == std::string::npos) | ||||
nNextDelimiterPos = nLen; | nNextDelimiterPos = nLen; | ||||
// Extract string between delimiters | // Extract string between delimiters | ||||
const size_t nSectionLen(nNextDelimiterPos - nSectionPos); | const size_t nSectionLen(nNextDelimiterPos - nSectionPos); | ||||
const std::string strSection(substr(nSectionPos, nSectionLen)); | const std::string strSection(substr(nSectionPos, nSectionLen)); | ||||
vwVecSplits.push_back(strSection.c_str()); | vwVecSplits.push_back(strSection); | ||||
// Next | // Next | ||||
nOffset = nNextDelimiterPos + 1; | nOffset = nNextDelimiterPos + 1; | ||||
} | } | ||||
while (nOffset < nLen); | while (nOffset < nLen); | ||||
return vwVecSplits.size(); | return vwVecSplits.size(); | ||||
} | } | ||||
Show All 39 Lines | do | ||||
return 0; | return 0; | ||||
} | } | ||||
if (nNextDelimiterPos == std::string::npos) | if (nNextDelimiterPos == std::string::npos) | ||||
nNextDelimiterPos = nLen; | nNextDelimiterPos = nLen; | ||||
// Extract string between delimiters | // Extract string between delimiters | ||||
const size_t nSectionLen(nNextDelimiterPos - nSectionPos); | const size_t nSectionLen(nNextDelimiterPos - nSectionPos); | ||||
const std::string strSection(substr(nSectionPos, nSectionLen)); | const std::string strSection(substr(nSectionPos, nSectionLen)); | ||||
vwVecSplits.push_back(strSection.c_str()); | vwVecSplits.push_back(strSection); | ||||
// Next | // Next | ||||
nOffset = nNextDelimiterPos + 1; | nOffset = nNextDelimiterPos + 1; | ||||
} | } | ||||
while (nOffset < nLen); | while (nOffset < nLen); | ||||
return vwVecSplits.size(); | return vwVecSplits.size(); | ||||
} | } | ||||
Show All 21 Lines | |||||
//-- | //-- | ||||
CMIUtilString | CMIUtilString | ||||
CMIUtilString::StripCREndOfLine() const | CMIUtilString::StripCREndOfLine() const | ||||
{ | { | ||||
const size_t nPos = rfind('\n'); | const size_t nPos = rfind('\n'); | ||||
if (nPos == std::string::npos) | if (nPos == std::string::npos) | ||||
return *this; | return *this; | ||||
const CMIUtilString strNew(substr(0, nPos).c_str()); | const CMIUtilString strNew(substr(0, nPos)); | ||||
return strNew; | return strNew; | ||||
} | } | ||||
//++ ------------------------------------------------------------------------------------ | //++ ------------------------------------------------------------------------------------ | ||||
// Details: Remove all '\n' from the string and replace with a space. It does not alter | // Details: Remove all '\n' from the string and replace with a space. It does not alter | ||||
// *this string. | // *this string. | ||||
// Type: Method. | // Type: Method. | ||||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | |||||
CMIUtilString | CMIUtilString | ||||
CMIUtilString::Trim() const | CMIUtilString::Trim() const | ||||
{ | { | ||||
CMIUtilString strNew(*this); | CMIUtilString strNew(*this); | ||||
const char *pWhiteSpace = " \t\n\v\f\r"; | const char *pWhiteSpace = " \t\n\v\f\r"; | ||||
const size_t nPos = find_last_not_of(pWhiteSpace); | const size_t nPos = find_last_not_of(pWhiteSpace); | ||||
if (nPos != std::string::npos) | if (nPos != std::string::npos) | ||||
{ | { | ||||
strNew = substr(0, nPos + 1).c_str(); | strNew = substr(0, nPos + 1); | ||||
} | } | ||||
const size_t nPos2 = strNew.find_first_not_of(pWhiteSpace); | const size_t nPos2 = strNew.find_first_not_of(pWhiteSpace); | ||||
if (nPos2 != std::string::npos) | if (nPos2 != std::string::npos) | ||||
{ | { | ||||
strNew = strNew.substr(nPos2).c_str(); | strNew = strNew.substr(nPos2); | ||||
} | } | ||||
return strNew; | return strNew; | ||||
} | } | ||||
//++ ------------------------------------------------------------------------------------ | //++ ------------------------------------------------------------------------------------ | ||||
// Details: Remove from either end of *this string the specified character. | // Details: Remove from either end of *this string the specified character. | ||||
// Type: Method. | // Type: Method. | ||||
// Args: None. | // Args: None. | ||||
// Return: CMIUtilString - Trimmed string. | // Return: CMIUtilString - Trimmed string. | ||||
// Throws: None. | // Throws: None. | ||||
//-- | //-- | ||||
CMIUtilString | CMIUtilString | ||||
CMIUtilString::Trim(const char vChar) const | CMIUtilString::Trim(const char vChar) const | ||||
{ | { | ||||
CMIUtilString strNew(*this); | CMIUtilString strNew(*this); | ||||
const size_t nLen = strNew.length(); | const size_t nLen = strNew.length(); | ||||
if (nLen > 1) | if (nLen > 1) | ||||
{ | { | ||||
if ((strNew[0] == vChar) && (strNew[nLen - 1] == vChar)) | if ((strNew[0] == vChar) && (strNew[nLen - 1] == vChar)) | ||||
strNew = strNew.substr(1, nLen - 2).c_str(); | strNew = strNew.substr(1, nLen - 2); | ||||
} | } | ||||
return strNew; | return strNew; | ||||
} | } | ||||
//++ ------------------------------------------------------------------------------------ | //++ ------------------------------------------------------------------------------------ | ||||
// Details: Do a printf equivalent for printing a number in binary i.e. "b%llB". | // Details: Do a printf equivalent for printing a number in binary i.e. "b%llB". | ||||
// Type: Static method. | // Type: Static method. | ||||
▲ Show 20 Lines • Show All 428 Lines • Show Last 20 Lines |