mirror of
https://github.com/debauchee/barrier.git
synced 2025-07-19 09:27:37 +02:00
Refactored string operations
Conflicts: src/lib/base/String.cpp
This commit is contained in:
parent
cb0f0dd06d
commit
39e183da3e
3 changed files with 50 additions and 11 deletions
|
@ -27,6 +27,9 @@
|
|||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <cstdarg>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
|
||||
namespace synergy {
|
||||
namespace string {
|
||||
|
@ -180,6 +183,30 @@ removeFileExt(String filename)
|
|||
return filename.substr(0, dot);
|
||||
}
|
||||
|
||||
void
|
||||
toHex(CString& subject, int width, const char fill)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << std::hex;
|
||||
for (unsigned int i = 0; i < subject.length(); i++) {
|
||||
ss << std::setw(width) << std::setfill(fill) << (int)(unsigned char)subject[i];
|
||||
}
|
||||
|
||||
subject = ss.str();
|
||||
}
|
||||
|
||||
void
|
||||
uppercase(CString& subject)
|
||||
{
|
||||
std::transform(subject.begin(), subject.end(), subject.begin(), ::toupper);
|
||||
}
|
||||
|
||||
void
|
||||
removeChar(CString& subject, const char c)
|
||||
{
|
||||
subject.erase(std::remove(subject.begin(), subject.end(), c), subject.end());
|
||||
}
|
||||
|
||||
//
|
||||
// CaselessCmp
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue