当前位置: 首页>>代码示例>>C++>>正文


C++ TrimRight函数代码示例

本文整理汇总了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();
}
开发者ID:ARTSAT,项目名称:data-remap,代码行数:9,代码来源:cTLE.cpp

示例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);
    }
开发者ID:xkmld419,项目名称:crawl,代码行数:61,代码来源:encode.cpp

示例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;
}
开发者ID:koz4k,项目名称:soccer,代码行数:43,代码来源:POP3.cpp

示例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);
}
开发者ID:MaChao5,项目名称:pdfviewer-win32,代码行数:10,代码来源:UnicodeString.cpp

示例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;
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:11,代码来源:Parser.cpp

示例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" );
				}
			}
		}
	}
}
开发者ID:goofwear,项目名称:stepmania,代码行数:53,代码来源:DebugInfoHunt.cpp

示例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);
}
开发者ID:0-T-0,项目名称:Serious-Engine,代码行数:13,代码来源:CTString.cpp

示例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);
}
开发者ID:SoftEtherVPN,项目名称:SoftEtherVPN,代码行数:15,代码来源:Str.c

示例9: Trim

// 文字列の左右の空白を削除
void Trim(char *str)
{
	// 引数チェック
	if (str == NULL)
	{
		return;
	}

	// 左側を trim
	TrimLeft(str);

	// 右側を trim
	TrimRight(str);
}
开发者ID:falcon8823,项目名称:utvpn,代码行数:15,代码来源:Str.c

示例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);
}
开发者ID:0-T-0,项目名称:Serious-Engine,代码行数:15,代码来源:CTString.cpp

示例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);
	}
}
开发者ID:JohnLonginotto,项目名称:ACGTrie,代码行数:50,代码来源:main.cpp

示例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;
}
开发者ID:macduff,项目名称:passwordsafe,代码行数:14,代码来源:StringX.cpp

示例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]);
}
开发者ID:Hydro8182,项目名称:taiga,代码行数:49,代码来源:list.cpp

示例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;
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:48,代码来源:RunDeviceDriver.cpp

示例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 !
    }
  }
}
开发者ID:joachimwieland,项目名称:xcsoar-jwieland,代码行数:16,代码来源:FlarmDetails.cpp


注:本文中的TrimRight函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。