本文整理汇总了C++中TrimRight函数的典型用法代码示例。如果您正苦于以下问题:C++ TrimRight函数的具体用法?C++ TrimRight怎么用?C++ TrimRight使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TrimRight函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TrimRight
cTle::cTle(string& strName, string& strLine1, string& strLine2)
{
m_strLine0 = strName;
m_strLine1 = strLine1;
m_strLine2 = strLine2;
TrimRight(m_strLine0);
Initialize();
}
示例2: decodepass
/*********************************************************
**************************解密函数************************
**************每输入16个字节密文得到8字节明文*************
***************最终只要用这个函数来解密即可***************
**********************************************************/
void decodepass(char *key,char *inblock,char * outblock)
{
int i,l;
char *inblocktemp, *outblocktemp,*temp;
if ( key==NULL || inblock==NULL)
{
strcpy(outblock, "");
return;
}
if (strlen(inblock)==0)
{
strcpy(outblock, "");
return;
}
l = strlen(key);
/* key must 8 char */
if (l>8)
key[8]='\0';
if (l<8)
for (i=8; i>l; i--)
strcat(key," ");
/* inblock must 16*n */
l = strlen(inblock) % 16;
if (l!=0)
for (i=16; i>l; i--)
strcat(inblock," ");
inblocktemp = (char *) malloc(17);
outblocktemp = (char *) malloc(9);
l = strlen(inblock);
bzero(outblock,strlen(outblock));
for (i=0; i<l; i+=16)
{
temp = &inblock[i];
strncpy(inblocktemp,temp,16);
DoDecDES16((A16 *)inblocktemp, key, (A8 *)outblocktemp);
outblocktemp[8]=0;
if (i==l-8)
outblocktemp = TrimRight(outblocktemp);
strcat(outblock,outblocktemp);
}
free(inblocktemp);
free(outblocktemp);
}
示例3: LLOG
bool Pop3::PutGet(const String& s, bool multiline, bool nolog)
{
// Put() request.
if(!s.IsEmpty()) {
if(!nolog)
LLOG(">> " << TrimRight(s));
if(!PutAll(s)) {
LLOG("-- " << GetLastError());
return false;
}
}
// Get() respone.
data.Clear();
const int MAXLINE = 20000000;
String line = GetLine(MAXLINE);
if(!line.IsVoid()) {
LLOG("<< " << TrimRight(line));
if(line.StartsWith("+OK")) {
if(!multiline) {
data.Cat(line);
data.Cat("\r\n");
return true;
}
else
for(;;) {
line = GetLine(MAXLINE);
if(line.IsVoid())
break;
if(line == ".") {
LLOG("<< ...");
return true;
}
data.Cat(*line == '.' ? line.Mid(1) : line);
data.Cat("\r\n");
}
}
else
if(line.StartsWith("-ERR"))
error = line;
}
LLOG("-- " << GetLastError());
return false;
}
示例4: ASSERT
void CUnicodeString::TrimRight(LPCSTR lpszTargets)
{
ASSERT(IsValidString(lpszTargets));
DWORD dwszLen = strlen(lpszTargets);
LPWSTR lpwsz = (LPWSTR)malloc((dwszLen + 1) * sizeof(WCHAR));
lpwsz[dwszLen] = L'\0';
MultiByteToWideChar(CP_ACP, 0, lpszTargets, dwszLen, lpwsz, dwszLen);
TrimRight(lpwsz);
free(lpwsz);
}
示例5:
CppItem& Parser::Item(const String& nameing, const String& nesting, const String& item)
{
CppItem& im = base->GetAdd(nameing).GetAdd(nesting).GetAdd(TrimRight(Purify(item)));
im.pname.Clear();
im.param.Clear();
im.package = package;
im.file = filename;
im.line = line + 1;
im.name.Clear();
return im;
}
示例6: GetDriveDebugInfoNT
static void GetDriveDebugInfoNT()
{
/*
* HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\
* Scsi Port *\
* DMAEnabled 0 or 1
* Driver "Ultra", "atapi", etc
* Scsi Bus *\
* Target Id *\
* Logical Unit Id *\
* Identifier "WDC WD1200JB-75CRA0"
* Type "DiskPeripheral"
*/
vector<RString> Ports;
if( !RegistryAccess::GetRegSubKeys( "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi", Ports ) )
return;
for( unsigned i = 0; i < Ports.size(); ++i )
{
int DMAEnabled = -1;
RegistryAccess::GetRegValue( Ports[i], "DMAEnabled", DMAEnabled );
RString Driver;
RegistryAccess::GetRegValue( Ports[i], "Driver", Driver );
vector<RString> Busses;
if( !RegistryAccess::GetRegSubKeys( Ports[i], Busses, "Scsi Bus .*" ) )
continue;
for( unsigned bus = 0; bus < Busses.size(); ++bus )
{
vector<RString> TargetIDs;
if( !RegistryAccess::GetRegSubKeys( Busses[bus], TargetIDs, "Target Id .*" ) )
continue;
for( unsigned tid = 0; tid < TargetIDs.size(); ++tid )
{
vector<RString> LUIDs;
if( !RegistryAccess::GetRegSubKeys( TargetIDs[tid], LUIDs, "Logical Unit Id .*" ) )
continue;
for( unsigned luid = 0; luid < LUIDs.size(); ++luid )
{
RString Identifier;
RegistryAccess::GetRegValue( LUIDs[luid], "Identifier", Identifier );
TrimRight( Identifier );
LOG->Info( "Drive: \"%s\" Driver: %s DMA: %s",
Identifier.c_str(), Driver.c_str(), DMAEnabled == 1? "yes":DMAEnabled == -1? "N/A":"NO" );
}
}
}
}
}
示例7: strchr
// retain only first line of the string
void CTString::OnlyFirstLine(void)
{
// get position of first line end
const char *pchNL = strchr(str_String, '\n');
// if none
if (pchNL==NULL) {
// do nothing
return;
}
// trim everything after that char
TrimRight(pchNL-str_String);
}
示例8: Trim
// Remove white spaces of the both side of the string
void Trim(char *str)
{
// Validate arguments
if (str == NULL)
{
return;
}
// Trim on the left side
TrimLeft(str);
// Trim on the right side
TrimRight(str);
}
示例9: Trim
// 文字列の左右の空白を削除
void Trim(char *str)
{
// 引数チェック
if (str == NULL)
{
return;
}
// 左側を trim
TrimLeft(str);
// 右側を trim
TrimRight(str);
}
示例10: TrimRight
/* Trim the string from from spaces from right. */
INDEX CTString::TrimSpacesRight(void)
{
// for each character in string reversed
const char *chr;
for(chr = str_String+strlen(str_String)-1; chr>str_String; chr--) {
// if the character is not space
if (!IsSpace(*chr)) {
// stop searching
break;
}
}
// trim to that character
return TrimRight(chr-str_String+1);
}
示例11: LoadDataToTrie
void LoadDataToTrie(CDnaTrieBuilder &trieBuilder, const std::string &inputFileName)
{
static const int c_maxStrLen = 16384;
FILE *f = stdin;
if (!inputFileName.empty())
f = fopen(inputFileName.c_str(), "r");
char buf[c_maxStrLen];
std::string str;
int readStrCount = 0;
if (!f)
THROW_EXCEPTION("Couldn't open input file");
buf[0] = 0;
while (true)
{
FUNC_GUARD
char *res = fgets(buf, c_maxStrLen, f);
str = buf;
TrimRight(str);
if (!res || str.empty())
{
printf("%d lines read\n", readStrCount);
trieBuilder.PrintCheckSum();
if (!inputFileName.empty())
fclose(f);
return;
}
std::string::size_type commaPos = str.rfind(',');
int count = -1;
if (commaPos == std::string::npos)
THROW_EXCEPTION("No comma in input string");
if (sscanf(str.c_str() + commaPos + 1, "%d", &count) != 1 || count <= 0)
THROW_EXCEPTION("Invalid DNA count");
str.resize(commaPos);
trieBuilder.AddDna(str, count);
readStrCount++;
if (readStrCount % (1 << 17) == 0)
printf("%d lines read\n", readStrCount);
}
}
示例12: main
int main(int argc, char *argv[])
{
if (argc != 2) {
cerr << "Usage: " << argv[0] << " string-to-trim" << endl;
exit(1);
}
StringX s(argv[1]), sl(argv[1]), sr(argv[1]);
Trim(s); TrimLeft(sl); TrimRight(sr);
cout << "Trim(\"" << argv[1] << "\") = \"" << s <<"\"" << endl;
cout << "TrimLeft(\"" << argv[1] << "\") = \"" << sl <<"\"" << endl;
cout << "TrimRight(\"" << argv[1] << "\") = \"" << sr <<"\"" << endl;
return 0;
}
示例13: SortAsFileSize
int SortAsFileSize(LPCWSTR str1, LPCWSTR str2) {
UINT64 size[2] = {1, 1};
for (size_t i = 0; i < 2; i++) {
std::wstring value = i == 0 ? str1 : str2;
std::wstring unit;
TrimRight(value, L".\r");
EraseChars(value, L" ");
if (value.length() >= 2) {
for (auto it = value.rbegin(); it != value.rend(); ++it) {
if (IsNumericChar(*it))
break;
unit.insert(unit.begin(), *it);
}
value.resize(value.length() - unit.length());
Trim(unit);
}
int index = InStr(value, L".");
if (index > -1) {
int length = value.substr(index + 1).length();
if (length <= 2)
value.append(2 - length, '0');
EraseChars(value, L".");
} else {
value.append(2, '0');
}
if (IsEqual(unit, L"KB")) {
size[i] *= 1000;
} else if (IsEqual(unit, L"KiB")) {
size[i] *= 1024;
} else if (IsEqual(unit, L"MB")) {
size[i] *= 1000 * 1000;
} else if (IsEqual(unit, L"MiB")) {
size[i] *= 1024 * 1024;
} else if (IsEqual(unit, L"GB")) {
size[i] *= 1000 * 1000 * 1000;
} else if (IsEqual(unit, L"GiB")) {
size[i] *= 1024 * 1024 * 1024;
}
size[i] *= _wtoi(value.c_str());
}
return CompareValues<UINT64>(size[0], size[1]);
}
示例14: main
int main(int argc, char **argv)
{
NarrowString<1024> usage;
usage = "DRIVER\n\n"
"Where DRIVER is one of:";
{
const DeviceRegister *driver;
for (unsigned i = 0; (driver = GetDriverByIndex(i)) != NULL; ++i) {
WideToUTF8Converter driver_name(driver->name);
usage.AppendFormat("\n\t%s", (const char *)driver_name);
}
}
Args args(argc, argv, usage);
tstring driver_name = args.ExpectNextT();
args.ExpectEnd();
driver = FindDriverByName(driver_name.c_str());
if (driver == NULL) {
_ftprintf(stderr, _T("No such driver: %s\n"), driver_name.c_str());
return 1;
}
DeviceConfig config;
config.Clear();
NullPort port;
Device *device = driver->CreateOnPort != NULL
? driver->CreateOnPort(config, port)
: NULL;
NMEAParser parser;
NMEAInfo data;
data.Reset();
char buffer[1024];
while (fgets(buffer, sizeof(buffer), stdin) != NULL) {
TrimRight(buffer);
if (device == NULL || !device->ParseNMEA(buffer, data))
parser.ParseLine(buffer, data);
}
Dump(data);
return EXIT_SUCCESS;
}
示例15: LoadSecondaryFile
static void
LoadSecondaryFile(TLineReader &reader)
{
TCHAR *line;
while ((line = reader.read()) != NULL) {
TCHAR *endptr;
FlarmId id;
id.parse(line, &endptr);
if (endptr > line && endptr[0] == _T('=') && endptr[1] != _T('\0')) {
TCHAR *Name = endptr + 1;
TrimRight(Name);
if (!FlarmDetails::AddSecondaryItem(id, Name))
break; // cant add anymore items !
}
}
}