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


C++ TrimString函数代码示例

本文整理汇总了C++中TrimString函数的典型用法代码示例。如果您正苦于以下问题:C++ TrimString函数的具体用法?C++ TrimString怎么用?C++ TrimString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TrimString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DoMonitor

//--------------------------------------------------------------------------------
bool DoMonitor(const char* pBuf, CTokenMaster*& pMaster)
	{
	if(pBuf == NULL)
		{
		printf("error ^^^^^^^\n");
		return false;
		}

	char sTemp[256];
	strcpy(sTemp, pBuf);

	char* pUser = sTemp;
	char* pPwd = strchr(sTemp, ',');
	if(pPwd == NULL)
		{
		printf("error ^^^^^^^ must be username, password\n");
		return false;
		}

	*pPwd = 0;
	pPwd++;

	strcpy(g_pMonitorUser, TrimString(sTemp));
	strcpy(g_pMonitorPwd, TrimString(pPwd));
	return true;
	}
开发者ID:moosethemooche,项目名称:Certificate-Server,代码行数:27,代码来源:TokenCompiler.cpp

示例2: GetConfigOptions

static bool GetConfigOptions(std::istream& stream, std::string& error, std::vector<std::pair<std::string, std::string>> &options)
{
    std::string str, prefix;
    std::string::size_type pos;
    int linenr = 1;
    while (std::getline(stream, str)) {
        if ((pos = str.find('#')) != std::string::npos) {
            str = str.substr(0, pos);
        }
        const static std::string pattern = " \t\r\n";
        str = TrimString(str, pattern);
        if (!str.empty()) {
            if (*str.begin() == '[' && *str.rbegin() == ']') {
                prefix = str.substr(1, str.size() - 2) + '.';
            } else if (*str.begin() == '-') {
                error = strprintf("parse error on line %i: %s, options in configuration file must be specified without leading -", linenr, str);
                return false;
            } else if ((pos = str.find('=')) != std::string::npos) {
                std::string name = prefix + TrimString(str.substr(0, pos), pattern);
                std::string value = TrimString(str.substr(pos + 1), pattern);
                options.emplace_back(name, value);
            } else {
                error = strprintf("parse error on line %i: %s", linenr, str);
                if (str.size() >= 2 && str.substr(0, 2) == "no") {
                    error += strprintf(", if you intended to specify a negated option, use %s=1 instead", str);
                }
                return false;
            }
        }
        ++linenr;
    }
    return true;
}
开发者ID:fujicoin,项目名称:fujicoin,代码行数:33,代码来源:util.cpp

示例3: USEINPUTKEY

void InputManager::Initialize()
{
#define USEINPUTKEY(e,hashVal,text) \
	_keyNameTable[ToUpper(text)] = e;
#include "InputKeys.h"
#undef USEINPUTKEY

	//Clear Xbox Button States
	ClearXboxButtonStates();
	
	StringList bindings;
	GetLinesFromFile("Config/input_bindings.ini", bindings);
	StringList::iterator it = bindings.begin();
	while (it != bindings.end())
	{
		if (((*it).size() == 0) || ((*it)[0] == ';'))
		{
			it++;
			continue;
		}
		StringList splitBinding = SplitString(*it, "=:", false);
		if (splitBinding.size() >= 2)
		{
			splitBinding[0] = TrimString(splitBinding[0]);
			splitBinding[1] = TrimString(splitBinding[1]);
			BindKey(splitBinding[0], splitBinding[1]);
		}
		it++;
	}
}
开发者ID:Ihsoyadbmal,项目名称:angel-engine,代码行数:30,代码来源:InputManager.cpp

示例4: while

/**
* Description:  GetFieldValue().    获取指定头域的内容
* @param  [in]  strField    所有头域字符串
* @param  [in]  strKey      头域Key值
* @param  [out] strContent  头域内容
* @param  [in]  strEnd          结束符
* @param  [in]  strInterval     分隔符
* @return       long.   返回码
*/
long CRtspPacket::GetFieldValue
(
    IN  const string&   strField,
    IN  const string&   strKey,
    OUT string&         strContent,
    IN  const string&   strEnd,
    IN  const string&   strInterval
)
{
    //先加一个结束符
    std::string strFieldTmp = strField + strEnd;//lint !e1036
    
    string strLine;
    string strValue;
    size_t nPosLineStart = 0;
    size_t nPosLineEnd = strFieldTmp.find(strEnd, nPosLineStart);

    long lResult = RTSP::RET_CODE_FAIL;
    
    while(string::npos != nPosLineEnd)
    {
        strLine = strFieldTmp.substr(nPosLineStart, nPosLineEnd - nPosLineStart);
    
        size_t nPosStart = 0;
        size_t nPosEnd = strLine.find(strInterval, nPosStart);

        //找到冒号,说明是某头域,进一步解析头域的值
        if (string::npos != nPosEnd)
        {
            strValue = strLine.substr(nPosStart, (nPosEnd - nPosStart));   //lint !e845

            //去掉字符串首尾的空格、Tab
            TrimString(strValue);

            //不区分大小写的比较,找到则直接退出
            if (0 == _strnicmp(strKey.c_str(), strValue.c_str(), strKey.length()))
            {
                //提取内容
                strContent = strLine.substr(nPosEnd + 1, nPosLineEnd - nPosEnd);
                //去掉字符串首尾的空格、Tab
                TrimString(strContent);
                
                lResult = RTSP::RET_CODE_OK;
                break;
            }
        }        

        //下一个行
        nPosLineStart = nPosLineEnd + strEnd.size();
        nPosLineEnd = strFieldTmp.find(strEnd, nPosLineStart);
    }
    
    return lResult;
}
开发者ID:rgmabs19357,项目名称:esdk_ivs_sdk_windows,代码行数:63,代码来源:RtspPacket.cpp

示例5: assert

void zs_ut_s::TrimString(char * str, int flag)
{
	assert(str != NULL);
	std::string s = str;
	TrimString(s, flag);
	strcpy(str, s.c_str());
}
开发者ID:beichentianyun,项目名称:zsummerX,代码行数:7,代码来源:utility.cpp

示例6: getline

bool CheatFileParser::Parse() {
	for (line_ = 1; file_ && !file_.eof(); ++line_) {
		std::string line;
		getline(file_, line, '\n');
		line = TrimString(line);

		// Minimum length is set to 5 just to match GetCodesList() function
		// which discards anything shorter when called anyway.
		// It's decided from shortest possible _ lines name of the game "_G N+"
		// and a minimum of 1 displayable character in cheat name string "_C0 1"
		// which both equal to 5 characters.
		if (line.length() >= 5 && line[0] == '_') {
			ParseLine(line);
		} else if (line.length() >= 2 && line[0] == '/' && line[1] == '/') {
			// Comment, ignore.
		} else if (line.length() >= 1 && line[0] == '#') {
			// Comment, ignore.
		} else if (line.length() > 0) {
			errors_.push_back(StringFromFormat("Unrecognized content on line %d: expecting _", line_));
		}
	}

	Flush();

	return errors_.empty();
}
开发者ID:orbea,项目名称:libretro-ppsspp,代码行数:26,代码来源:CwCheat.cpp

示例7: strstr

const char * StringUtils::ExtractPropertyName(const char *a_buffer, const char *a_delim)
{
	// Early out for bad string or no delim
	const char * delimLoc = strstr(a_buffer, a_delim);
	if (a_buffer == NULL || 
		strlen(a_buffer) == 0 || 
		delimLoc == NULL)
	{
		return NULL;
	}
   
    // Alloc a new string and return it
	unsigned int propLength = delimLoc - a_buffer;
	char * retBuf = (char*)malloc(sizeof(char)*propLength+1);
	if (retBuf != NULL)
	{
		// Copy all chars up to delim and null terminate
		memset(retBuf, 0, sizeof(char) * propLength);
		memcpy(retBuf, a_buffer, propLength);
		retBuf[propLength] = '\0';
		return TrimString(retBuf);
    }
	
	// Failure case
	return NULL;
}
开发者ID:macBdog,项目名称:game,代码行数:26,代码来源:Stringutils.cpp

示例8: IsFlashRequest

// This is the heuristic which detects the requests issued by Flash.ocx.
// It turned out that the implementation from ''Flash.ocx'' (tested version is 15.0.0.152)
// returns quite minimal configuration in comparison with the implementation from Microsofts'
// libraries (see grfBINDF and bindInfo.dwOptions). The impl from MS often includes something
// else.
bool WBPassthruSink::IsFlashRequest(const wchar_t* const* additionalHeaders)
{
  if (additionalHeaders && *additionalHeaders)
  {
    auto flashVersionHeader = ExtractHttpHeader<std::wstring>(*additionalHeaders, L"x-flash-version:", L"\n");
    if (!TrimString(flashVersionHeader).empty())
    {
      return true;
    }
  }
  ATL::CComPtr<IBindStatusCallback> bscb;
  if (SUCCEEDED(QueryServiceFromClient(&bscb)) && !!bscb)
  {
    DWORD grfBINDF = 0;
    BINDINFO bindInfo = {};
    bindInfo.cbSize = sizeof(bindInfo);
    if (SUCCEEDED(bscb->GetBindInfo(&grfBINDF, &bindInfo)) &&
      (BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE| BINDF_PULLDATA) == grfBINDF &&
      (BINDINFO_OPTIONS_ENABLE_UTF8 | BINDINFO_OPTIONS_USE_IE_ENCODING) == bindInfo.dwOptions
      )
    {
      return true;
    }
  }
  return false;
}
开发者ID:junaidnaseer,项目名称:adblockplusie,代码行数:31,代码来源:PluginWbPassThrough.cpp

示例9: do_GMEndGame

void do_GMEndGame(CPC *a1, char *a2)
{
    int v3; // [sp+24h] [bp-4h]@4
    char *sa; // [sp+34h] [bp+Ch]@4

    if(!a2 || !*a2)
        return;

    sa = AnyOneArg(a2, g_buf, false);
    v3 = atoi(g_buf);
    TrimString(sa);

    if(gserver.Unk41088 != -1)
        return;

    gserver.Unk41088 = 10 * v3;

    if(!*sa)
        return;

    CNetMsg v2;

    MsgrNoticeMsg(v2, -1, -1, -1, -1, sa);

    if(!gserver.Unk452129 && gserver.Unk12 && !gserver.Unk12->Unk361)
    {
        if(gserver.Unk12)
            gserver.Unk12->WriteToOutput(v2);
    }
}
开发者ID:Christian-Roggia,项目名称:open-last-chaos,代码行数:30,代码来源:doFuncAdmin.cpp

示例10: do_GMQuestComplete

void do_GMQuestComplete(CPC *a1, char *a2)
{
    int v10; // [sp+34h] [bp-4h]@5

    if(a2 && *a2)
    {
        TrimString(a2);
        if(strlen(a2))
        {
            v10 = atoi(a2);
            for(int i = 0; i <= 9; ++i)
            {
                if(a1->Unk1900.Unk0[i] && a1->Unk1900.Unk40[i] && !a1->Unk1900.Unk50[i] && a1->Unk1900.Unk0[i]->Unk0->Unk0 == v10)
                {
                    g_gamelogbuffer.__ls(init("QUEST COMPLETE"));
                    g_gamelogbuffer.__ls(a1->Unk8);
                    g_gamelogbuffer.__ls(delim);
                    g_gamelogbuffer.__ls(a1->Unk1900.Unk0[i]->Unk0->Unk0);
                    g_gamelogbuffer.__ls(end);

                    CNetMsg v7;

                    QuestCompleteMsg(v7, a1->Unk1900.Unk0[i]);
                    if(a1->Unk768)
                        a1->Unk768->WriteToOutput(v7);

                    a1->Unk1900.Unk50[i] = 1;
                    return;
                }
            }
        }
    }
}
开发者ID:Christian-Roggia,项目名称:open-last-chaos,代码行数:33,代码来源:doFuncAdmin.cpp

示例11: TrimXmlContent

bool zs_ut_s::GetXmlParam(std::string content, std::string param, std::vector<std::string> & data)
{
	TrimXmlContent(content);

	data.clear();
	std::string preParam = "<";
	preParam += param;
	preParam += ">";
	std::string suffParam = "</";
	suffParam += param;
	suffParam += ">";

	std::string::size_type pos1 = 0;
	while(1)
	{
		pos1 = content.find(preParam, pos1);
		if (pos1 == std::string::npos)
		{
			break;
		}
		pos1 += preParam.length();
		std::string::size_type pos2 = content.find(suffParam, pos1);
		if (pos2 == std::string::npos)
		{
			break;
		}

		data.push_back(content.substr(pos1, pos2-pos1));
		TrimString(data.back());
	}
	return true;
}
开发者ID:beichentianyun,项目名称:zsummerX,代码行数:32,代码来源:utility.cpp

示例12: defined

std::vector<std::string> CWCheatEngine::GetCodesList() {
	// Reads the entire cheat list from the appropriate .ini.
	std::vector<std::string> codesList;
#if defined(_WIN32) && !defined(__MINGW32__)
	std::ifstream list(ConvertUTF8ToWString(activeCheatFile));
#else
	std::ifstream list(activeCheatFile.c_str());
#endif
	while (list && !list.eof()) {
		std::string line;
		getline(list, line, '\n');

		bool validCheatLine = false;
		// This function is called by cheat menu(UI) which doesn't support empty names
		// minimum 1 non space character is required starting from 5 position.
		// It also goes through other "_" lines, but they all have to meet this requirement anyway
		// so we don't have to specify any syntax checks here that are made by cheat engine.
		if (line.length() >= 5 && line[0] == '_') {
			for (size_t i = 4; i < line.length(); i++) {
				if (line[i] != ' ') {
					validCheatLine = true;
					break;
				}
			}
		}
		// Any lines not passing this check are discarded when we save changes to the cheat ini file
		if (validCheatLine || (line.length() >= 2 && line[0] == '/' && line[1] == '/') || (line.length() >= 1 && line[0] == '#')) {
			codesList.push_back(TrimString(line));
		}
	}
	return codesList;
}
开发者ID:orbea,项目名称:libretro-ppsspp,代码行数:32,代码来源:CwCheat.cpp

示例13: StringSplit

bool cCraftingRecipes::ParseItem(const AString & a_String, cItem & a_Item)
{
	// The caller provides error logging
	
	AStringVector Split = StringSplit(a_String, "^");
	if (Split.empty())
	{
		return false;
	}
	
	if (!StringToItem(Split[0], a_Item))
	{
		return false;
	}
	
	if (Split.size() > 1)
	{
		AString Damage = TrimString(Split[1]);
		if (!StringToInteger<short>(Damage.c_str(), a_Item.m_ItemDamage))
		{
			// Parsing the number failed
			return false;
		}
	}
	
	// Success
	return true;
}
开发者ID:DjKiDD,项目名称:MCServer,代码行数:28,代码来源:CraftingRecipes.cpp

示例14: LOGV

status_t StagefrightRecorder::setParameters(const String8 &params) {
    LOGV("setParameters: %s", params.string());
    const char *cparams = params.string();
    const char *key_start = cparams;
    for (;;) {
        const char *equal_pos = strchr(key_start, '=');
        if (equal_pos == NULL) {
            LOGE("Parameters %s miss a value", cparams);
            return BAD_VALUE;
        }
        String8 key(key_start, equal_pos - key_start);
        TrimString(&key);
        if (key.length() == 0) {
            LOGE("Parameters %s contains an empty key", cparams);
            return BAD_VALUE;
        }
        const char *value_start = equal_pos + 1;
        const char *semicolon_pos = strchr(value_start, ';');
        String8 value;
        if (semicolon_pos == NULL) {
            value.setTo(value_start);
        } else {
            value.setTo(value_start, semicolon_pos - value_start);
        }
        if (setParameter(key, value) != OK) {
            return BAD_VALUE;
        }
        if (semicolon_pos == NULL) {
            break;  // Reaches the end
        }
        key_start = semicolon_pos + 1;
    }
    return OK;
}
开发者ID:SciAps,项目名称:android-frameworks-base,代码行数:34,代码来源:StagefrightRecorder.cpp

示例15: MsgEventAdded

static int MsgEventAdded(WPARAM wParam,LPARAM lParam)
{
	HANDLE hDbEvent = (HANDLE)lParam;

	if (currentWatcherType & SDWTF_MESSAGE) {
		DBEVENTINFO dbe = { sizeof(dbe) };
		dbe.cbBlob = db_event_getBlobSize(hDbEvent);
		dbe.pBlob = (BYTE*)mir_alloc(dbe.cbBlob+2); /* ensure term zero */
		if (dbe.pBlob == NULL)
			return 0;
		if (!db_event_get(hDbEvent, &dbe))
			if (dbe.eventType == EVENTTYPE_MESSAGE && !(dbe.flags & DBEF_SENT)) {
				DBVARIANT dbv;
				if (!db_get_ts(NULL,"AutoShutdown","Message",&dbv)) {
					TrimString(dbv.ptszVal);
					TCHAR *pszMsg = GetMessageText(&dbe.pBlob,&dbe.cbBlob);
					if (pszMsg != NULL && _tcsstr(pszMsg,dbv.ptszVal) != NULL)
						ShutdownAndStopWatcher(); /* msg with specified text recvd */
					mir_free(dbv.ptszVal); /* does NULL check */
				}
			}
		mir_free(dbe.pBlob);
	}
	return 0;
}
开发者ID:MrtsComputers,项目名称:miranda-ng,代码行数:25,代码来源:watcher.cpp


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