示例#1
0
文件: trie.c 项目: qhsong/EmailSearch
void trie(FILE *pool,FILE *check,FILE *result) {
    TRIE *head = trie_create();
    char line[BUFFERSIZE];
    int exitflag=0;
    int i;
    while(fgets(line,BUFFERSIZE,pool)) {
        /*delete the useless character '\r'*/
        exitflag = trimString(line);
        if(!exitflag) {
            reverseString(line);
            trie_add(&head,line);
        } else {
            /*printf("Error email %s",line);*/
            continue;
        }
    }
    while(fgets(line,BUFFERSIZE,check)) {

        i = 0;
        while(line[i]!='\r' && line[i]!='\n') i++;
        line[i] = '\0';
        exitflag = trimString(line);
        if(!exitflag) {
            reverseString(line);
            if(trie_check(&head,line)) {
                fprintf(result,"yes\n");
            } else {
                fprintf(result,"no\n");
            }
        }
    }
    trie_destroy(&head);
}
void ConfigFileReader::processLine (std::string &str)
{
	if (str=="")
		return;
	int index = str.find ('=');
	
	if (index == 0 || index == str.size())
	{
		error = true;
		errorMessage = "Invalid line in config file";
		return;
	}
	
	std::string key = str.substr (0 , index);

	std::string value = str.substr (index + 1, str.size()-index-1);
	
	trimString(key);
	trimString(value);
	
		
	if (key == "" || value == "")
	{
		error = true;
		errorMessage = "Invalid line in config file";
		return;
	}
	
	(*keyValueMap) [key] = value;
}
示例#3
0
TableFormater& TableFormater::operator<<(DoubleParameter in)
{
	if(curCol==0) *out << firstSep+" ";
	else *out << " "<<sep<<" ";
	if(in.HasError()){
		std::string tmp;
		if(in.GetErrorType()==ErrorType::SYM && in.GetError()!=0){
			unsigned int halfWidth = (unsigned int)(columnWidth[curCol])/2;//divide column width
			*out << std::setw(halfWidth) << in.GetValue();
			tmp = pm+std::to_string((long double) in.GetError()); trimString(tmp);
			*out << std::setw(halfWidth) << tmp;
		} else if(in.GetErrorType()==ErrorType::ASYM){
			unsigned int w = (unsigned int)(columnWidth[curCol])/3;//take 1/3 of column width
			tmp = std::to_string((long double) in.GetValue()); trimString(tmp);
			*out << std::setw(w) << tmp;
			tmp = "-"+std::to_string((long double) in.GetErrorLow());trimString(tmp);
			*out << std::setw(w) << tmp;
			tmp = "+"+std::to_string((long double) in.GetErrorHigh());trimString(tmp);
			*out << std::setw(w) << tmp;
		} else
			*out << std::setw(columnWidth[curCol]) << in.GetValue();
	} else {
		*out << std::setw(columnWidth[curCol]) << in.GetValue();
	}
	curCol++;
	if(curCol==columnWidth.size()) {
		*out<<" "<<lastSep<<std::endl;
		curRow++; curCol=0;
	}
	return *this;
}
示例#4
0
void ProtocolAdmin::adminCommandSetOwner(const std::string& param)
{
	OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);

	if (output) {
		boost::char_separator<char> sep(", ");
		tokenizer cmdtokens(param, sep);
		tokenizer::iterator cmdit = cmdtokens.begin();
		std::string _house, name;
		_house = parseParams(cmdit, cmdtokens.end());
		name = parseParams(cmdit, cmdtokens.end());
		trimString(_house);
		trimString(name);

		if (House* house = Houses::getInstance().getHouse(atoi(_house.c_str()))) {
			uint32_t _guid;

			if (IOLoginData::getInstance()->getGuidByName(_guid, name)) {
				house->setHouseOwner(_guid);
				addLogLine(this, LOGTYPE_EVENT, 1, "set " + name + " as new owner of house with id " + _house);
				output->AddByte(AP_MSG_COMMAND_OK);
			} else {
				addLogLine(this, LOGTYPE_WARNING, 1, "Could not find player with name: " + name);
				output->AddByte(AP_MSG_COMMAND_FAILED);
				output->AddString("such player does not exists");
			}
		} else {
			addLogLine(this, LOGTYPE_WARNING, 1, "Could not find house with id: " + _house);
			output->AddByte(AP_MSG_COMMAND_FAILED);
			output->AddString("such house does not exists");
		}

		OutputMessagePool::getInstance()->send(output);
	}
}
示例#5
0
文件: house.cpp 项目: CkyLua/tfs
bool AccessList::parseList(const std::string& _list)
{
	playerList.clear();
	guildList.clear();
	expressionList.clear();
	regExList.clear();
	list = _list;
	if(_list == "")
		return true;

	std::istringstream listStream(_list);
	std::string line;
	while(getline(listStream, line))
	{
		trimString(line);
		trim_left(line, "\t");
		trim_right(line, "\t");
		trimString(line);

		std::transform(line.begin(), line.end(), line.begin(), tolower);
		if(line.substr(0,1) == "#" || line.length() > 100)
			continue;

		if(line.find("@") != std::string::npos)
		{
			std::string::size_type pos = line.find("@");
			addGuild(line.substr(pos + 1), "");
		}
		else if(line.find("!") != std::string::npos || line.find("*") != std::string::npos || line.find("?") != std::string::npos)
			addExpression(line);
		else
			addPlayer(line);
	}
	return true;
}
示例#6
0
void Commands::addSkill(Player* player, const std::string& cmd, const std::string& param)
{
	boost::char_separator<char> sep(",");
	tokenizer cmdtokens(param, sep);
	tokenizer::iterator cmdit = cmdtokens.begin();
	std::string param1, param2;
	param1 = parseParams(cmdit, cmdtokens.end());
	param2 = parseParams(cmdit, cmdtokens.end());
	trimString(param1);
	trimString(param2);
	toLowerCaseString(param2);

	Player* paramPlayer = g_game.getPlayerByName(param1);

	if (!paramPlayer) {
		player->sendTextMessage(MSG_STATUS_SMALL, "Couldn't find target.");
		return;
	}

	if (param2[0] == 'l' || param2[0] == 'e') {
		paramPlayer->addExperience(Player::getExpForLevel(paramPlayer->getLevel() + 1) - paramPlayer->experience, false, false);
	} else if (param2[0] == 'm') {
		paramPlayer->addManaSpent(paramPlayer->vocation->getReqMana(paramPlayer->getBaseMagicLevel() + 1) - paramPlayer->manaSpent, false);
	} else {
		skills_t skillId = getSkillId(param2);
		paramPlayer->addSkillAdvance(skillId, paramPlayer->vocation->getReqSkillTries(skillId, paramPlayer->getSkill(skillId, SKILL_LEVEL) + 1));
	}
}
示例#7
0
void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
{
	u32 encoded;

	auto memLock = Memory::Lock();
	if (Core_IsStepping() == false) {
		MessageBox(wnd,L"Cannot change code while the core is running!",L"Error",MB_OK);
		return;
	}
	std::string op;
	bool result = InputBox_GetString(MainWindow::GetHInstance(),wnd,L"Assemble opcode",defaultText, op, false);
	if (!result)
		return;

	// check if it changes registers first
	auto seperator = op.find('=');
	if (seperator != std::string::npos)
	{
		std::string registerName = trimString(op.substr(0,seperator));
		std::string expression = trimString(op.substr(seperator+1));

		u32 value;
		if (parseExpression(expression.c_str(),debugger,value) == true)
		{
			for (int cat = 0; cat < debugger->GetNumCategories(); cat++)
			{
				for (int reg = 0; reg < debugger->GetNumRegsInCategory(cat); reg++)
				{
					if (strcasecmp(debugger->GetRegName(cat,reg),registerName.c_str()) == 0)
					{
						debugger->SetRegValue(cat,reg,value);
						SendMessage(GetParent(wnd),WM_DEB_UPDATE,0,0);
						return;
					}
				}
			}
		}

		// try to assemble the input if it failed
	}

	result = MIPSAsm::MipsAssembleOpcode(op.c_str(),debugger,address,encoded);
	if (result == true)
	{
		Memory::Write_U32(encoded, address);
		// In case this is a delay slot or combined instruction, clear cache above it too.
		if (MIPSComp::jit)
			MIPSComp::jit->InvalidateCacheAt(address - 4, 8);
		scanFunctions();

		if (address == curAddress)
			gotoAddr(manager.getNthNextAddress(curAddress,1));

		redraw();
	} else {
		std::wstring error = ConvertUTF8ToWString(MIPSAsm::GetAssembleError());
		MessageBox(wnd,error.c_str(),L"Error",MB_OK);
	}
}
void parseLine(const char* str, char* prefix, char* data)
{	
	char* pch = strchr(str, '=');
	strncpy(prefix, str, pch - str);
	trimString(prefix);
	strcpy(data, pch + 1);
	trimString(data);
}
示例#9
0
bool Mailbox::getReceiver(Item* item, std::string& name, uint32_t& dp)
{
	if(!item)
		return false;

	if(item->getID() == ITEM_PARCEL) /**We need to get the text from the label incase its a parcel**/
	{
		Container* parcel = item->getContainer();
		if(parcel)
		{
			for(ItemList::const_iterator cit = parcel->getItems(); cit != parcel->getEnd(); cit++)
			{
				if((*cit)->getID() == ITEM_LABEL)
				{
					item = (*cit);
					if(item->getText() != "")
						break;
				}
			}
		}
	}
	else if(item->getID() != ITEM_LETTER) /**The item is somehow not a parcel or letter**/
	{
		std::cout << "Mailbox::getReciver error, trying to get reciecer from unkown item! ID:: " << item->getID() << "." << std::endl;
		return false;
	}

	if(!item || item->getText() == "") /**No label/letter found or its empty.**/
		return false;

	std::string temp;
	std::istringstream iss(item->getText(), std::istringstream::in);
	std::string strTown = "";
	uint32_t curLine = 1;

	while(getline(iss, temp, '\n'))
	{
		if(curLine == 1)
			name = temp;
		else if(curLine == 2)
			strTown = temp;
		else
			break;

		++curLine;
	}

	trimString(name);
	trimString(strTown);

	Town* town = Towns::getInstance().getTown(strTown);
	if(town)
	{
		dp = town->getTownID();
		return true;
	}
	return false;
}
示例#10
0
void CStringTest::testTrimWhiteSpace()
{
        std::string String(" test this ");

        String = trimString(String);
        CPPUNIT_ASSERT(String == "test this");

        String = "\"test this\"";

        String = trimString(String," \t\"");
        CPPUNIT_ASSERT(String == "test this");
}
示例#11
0
char *getResult(char input1[],char input2[])
{
	char *result="error";
	trimString(input1);
	trimString(input2);
	if(isValid(input1)&&isValid(input2))
	{
		result=NBitBinaryAdder(input1,input2);
		reverse(result,inputlen(result));
	}
	return result;
}
示例#12
0
TalkActionResult_t Spells::playerSaySpell(Player* player, std::string& words)
{
	std::string str_words = words;

	//strip trailing spaces
	trimString(str_words);

	InstantSpell* instantSpell = getInstantSpell(str_words);
	if (!instantSpell) {
		return TALKACTION_CONTINUE;
	}

	std::string param;

	if (instantSpell->getHasParam()) {
		size_t spellLen = instantSpell->getWords().length();
		size_t paramLen = str_words.length() - spellLen;
		std::string paramText = str_words.substr(spellLen, paramLen);
		if (!paramText.empty() && paramText.front() == ' ') {
			size_t loc1 = paramText.find('"', 1);
			if (loc1 != std::string::npos) {
				size_t loc2 = paramText.find('"', loc1 + 1);
				if (loc2 == std::string::npos) {
					loc2 = paramText.length();
				} else if (paramText.find_last_not_of(' ') != loc2) {
					return TALKACTION_CONTINUE;
				}

				param = paramText.substr(loc1 + 1, loc2 - loc1 - 1);
			} else {
				trimString(paramText);
				loc1 = paramText.find(' ', 0);
				if (loc1 == std::string::npos) {
					param = paramText;
				} else {
					return TALKACTION_CONTINUE;
				}
			}
		}
	}

	if (instantSpell->playerCastInstant(player, param)) {
		words = instantSpell->getWords();

		if (instantSpell->getHasParam() && !param.empty()) {
			words += " \"" + param + "\"";
		}

		return TALKACTION_BREAK;
	}

	return TALKACTION_FAILED;
}
示例#13
0
bool Mailbox::getRecipient(Item* item, std::string& name, uint32_t& depotId)
{
	if(!item)
		return false;

	if(item->getID() == ITEM_PARCEL) /**We need to get the text from the label incase its a parcel**/
	{
		if(Container* parcel = item->getContainer())
		{
			for(ItemList::const_iterator cit = parcel->getItems(); cit != parcel->getEnd(); ++cit)
			{
				if((*cit)->getID() == ITEM_LABEL && !(*cit)->getText().empty())
				{
					item = (*cit);
					break;
				}
			}
		}
	}
	else if(item->getID() != ITEM_LETTER) /**The item is somehow not a parcel or letter**/
	{
		std::clog << "[Error - Mailbox::getReciver] Trying to get receiver from unkown item with id: " << item->getID() << "!" << std::endl;
		return false;
	}

	if(!item || item->getText().empty()) /**No label/letter found or its empty.**/
		return false;

	std::istringstream iss(item->getText(), std::istringstream::in);
	uint32_t curLine = 0;

	std::string tmp, townString;
	while(getline(iss, tmp, '\n') && curLine < 2)
	{
		if(curLine == 0)
			name = tmp;
		else if(curLine == 1)
			townString = tmp;

		++curLine;
	}

	trimString(name);
	if(townString.empty())
		return false;

	trimString(townString);
	return getDepotId(townString, depotId);
}
Production::Production(ifstream& infile)
{	
   	// Get Production line to parse.
   	const size_t MAX_CHAR_ARRAY_SIZE = 1000;
	char tempString[MAX_CHAR_ARRAY_SIZE];
	infile.getline(tempString, MAX_CHAR_ARRAY_SIZE, '\n');
	
	// Convert to string object for better manipulation.
	string rawStringObject = tempString;
	string trimmedString = trimString(rawStringObject);

	// Prepare punctuation.
	formatForPunctuation(trimmedString);
	
	// Turn string into a stream for word easy extraction.
	stringstream myStringStream(trimmedString);

	// Loop through; extract and store all words in vector.
	string temp;
	myStringStream >> temp;
	while(temp != ";")
	{
		this->phrases.push_back(temp);
		
		myStringStream >> temp;
	}

}
示例#15
0
char OSISLemma::processText(std::string &text, const SWKey *key, const SWModule *module) {
    (void) key;
    (void) module;
    std::string token;
    bool intoken = false;

    const std::string orig = text;
    const char * from = orig.c_str();

    if (!option) {
        for (text = ""; *from; ++from) {
            if (*from == '<') {
                intoken = true;
                token = "";
                continue;
            }
            if (*from == '>') {    // process tokens
                intoken = false;
                if (hasPrefix(token, "w ")) {    // Word
                    XMLTag wtag(token.c_str());
                    int count = wtag.getAttributePartCount("lemma", ' ');
                    for (int i = 0; i < count; i++) {
                        std::string a = wtag.getAttribute("lemma", i, ' ');
                        auto const prefixPos(a.find(':'));
                        if (prefixPos == std::string::npos
                            || (prefixPos >= sizeof("lemma.") - 1u
                                && std::strncmp(a.c_str(),
                                                "lemma.",
                                                sizeof("lemma.") - 1u)))
                        {
                            // remove attribute part
                            wtag.setAttribute("lemma", 0, i, ' ');
                            i--;
                            count--;
                        }
                    }
                    token = wtag;
                    trimString(token);
                    // drop <>
                    token.erase(0u, 1u);
                    token.pop_back();
                }

                // keep token in text
                text.push_back('<');
                text.append(token);
                text.push_back('>');

                continue;
            }
            if (intoken) {
                token += *from;
            }
            else    {
                text.push_back(*from);
            }
        }
    }
    return 0;
}
示例#16
0
bool Mailbox::getReceiver(Item* item, std::string& name)
{
	if (!item) {
		return false;
	}

	if (item->getID() == ITEM_PARCEL) { /**We need to get the text from the label incase its a parcel**/
		Container* parcel = item->getContainer();
		if (parcel) {
			for (ItemDeque::const_iterator cit = parcel->getItems(), end = parcel->getEnd(); cit != end; ++cit) {
				if ((*cit)->getID() == ITEM_LABEL) {
					item = (*cit);
					if (!item->getText().empty()) {
						break;
					}
				}
			}
		}
	} else if (item->getID() != ITEM_LETTER) { /**The item is somehow not a parcel or letter**/
		std::cout << "Mailbox::getReciver error, trying to get reciecer from unkown item! ID: " << item->getID() << "." << std::endl;
		return false;
	}

	if (!item || item->getText().empty()) { /**No label/letter found or its empty.**/
		return false;
	}

	name = getFirstLine(item->getText());
	trimString(name);
	return true;
}
示例#17
0
void parsePath(AllData& alldata, string path, int rule, uint64_t n,
		double timeB) {
	trimString(path);
	if (rule != 1) {
		timeB = -1;
	}

	cur_pos = NULL;
	uint32_t cid;
	string child;
	while (path != "") {
		uint32_t pid = atoi(path.substr(0, path.find_first_of(" ")).c_str());
		string parent = alldata.functionIdNameMap[pid];
		path = path.substr(path.find_first_of(" ") + 1);
		if (path == "") {
			if (cur_pos != NULL)
				break;
			cid = 5;
			child = parent;
			child = "";
		} else {
			cid = atoi(path.substr(0, path.find_first_of(" ")).c_str());
			child = alldata.functionIdNameMap[cid];
		}

		if (path.find_first_of(" ") == path.npos) {
			addToTree(parent, pid, child, cid, rule, n, timeB);
			break;
		} else
			addToTree(parent, pid, child, cid, -1, 0, -1);
	}
}
示例#18
0
void inputTestCases()
{
	int i;
	struct testcases test[12] = {
				{"1010","0101","1111"},
				{"0000","0000","0000"},
				{"1111 1111","i111 1111","error"},
				{"0 0 0 0 0 0 0 0 0","0 0 1 1","0 0 0 0 0 0 0 1 1"},
				{"11 00","00 11","11 11"},
				{"","   111   ","111"},
				{"1111 1111","","11 1111 11"},
				{"11 11","1+ 11","error"},
				{"1 0 101","1 01","1 1 010"},
				{"1","1","1 0"},
				{" 0 "," 1 "," 1 "},
				{"","",""}
			};
	char *finalresult,*myinput1,*myinput2,*myoutput;
	for(i=0;i<12;i++)
	{
		myinput1 = (char *)malloc(inputlen(test[i].input1)*sizeof(char));
		myinput2 = (char *)malloc(inputlen(test[i].input2)*sizeof(char));
		myoutput = (char *)malloc(inputlen(test[i].output)*sizeof(char));
		stringCopy(myinput1,test[i].input1);
		stringCopy(myinput2,test[i].input2);
		stringCopy(myoutput,test[i].output);
		trimString(myoutput);
		finalresult = getResult(myinput1,myinput2);
		if(isEqual(finalresult,myoutput))
			printf("pass\n");
		else
			printf("fail\n");
	}
}
示例#19
0
void get_config_info()
{
	char line[512] = "";
	char *token, *ptr;
	FILE* fp = fopen(WEB_CONFIG_CONF, "r");

	if (fp != NULL)
	{
		while (fgets(line, sizeof(line), fp))
		{
			token = strtok_r(line, "=", &ptr);
			trimString(ptr);
			if (strcmp(token, "filepath") == 0)
			{
				strcpy(DataPath, ptr);
			}
		}
		fclose(fp);

		logger_remotem("DataPath: %s", DataPath);
	}
	else
	{
		logger_remotem("GET_INFO: cannot open  config file - %s", WEB_CONFIG_CONF);
	}
}
示例#20
0
bool XMLWrapper::nodeDump(xmlNodePtr node, std::string &content, bool trim)
{
	content.clear();

	if (!mDocument) {
		return false;
	}

	if (!node) {
		return false;
	}

	bool result = false;

	xmlBufferPtr buffer = xmlBufferCreate();
	if (buffer) {
		xmlOutputBufferPtr outputBuffer = xmlOutputBufferCreateBuffer(buffer, NULL);
		if (outputBuffer) {
			xmlNodeDumpOutput(outputBuffer, mDocument, node, 0, 0, "UTF8");
			xmlOutputBufferClose(outputBuffer);
			outputBuffer = NULL;

			result = convertToString(buffer->content, content);

			if (result && trim) {
				trimString(content);
			}
		}
		xmlBufferFree(buffer);
		buffer = NULL;
	}

	return result;
}
示例#21
0
vector<char*> read_file(char* filename)
{
	vector<char*> file_data;
	ifstream inData;

	inData.open(filename, ios::in);
	if(!inData)
	{
		printf("the file %s can not be opened\n", filename);
		inData.close();
		exit(1); 
	}
	//buffer to hold one line data 
	char str[MAXDATASIZE];
	memset(str, 0, MAXDATASIZE);
	while(inData.getline(str, MAXDATASIZE))
	{
		trimString(str);
		int len = strlen(str);
		if(len == 0)
			continue;
		char* data_str = new char[len];
		memset(data_str, 0, len);
		strcpy(data_str, str);
		file_data.push_back(data_str);
		memset(str, 0, MAXDATASIZE);
	}	
	
	inData.close();
	return file_data;
}
示例#22
0
vector<string> readFile(char* filename)
{
	vector<string> file_data;
	
	FILE* pFile = fopen(filename, "r");
	if(!pFile)
	{
		fprintf(stderr, "cannot open file %s\n", filename);
		return file_data;
	}
	char str[MAXDATASIZE];
	memset(str, 0, MAXDATASIZE);
	while(!feof(pFile))
	{
		memset(str, 0, MAXDATASIZE);
		if(fgets(str, MAXDATASIZE, pFile) != NULL)
		{
			trimString(str);
			int len = strlen(str);
			if(len == 0)
				continue;
			memset(&str[len - 2], 0, 2);	
			string s(str);
			file_data.push_back(s);	
		}
	}
	return file_data;
}
示例#23
0
文件: Parser.cpp 项目: miyucy/swfmill
void Parser::doParse(const char* str) {
	string tmp;
		
	insideParams = false;
	params.clear();

	for (size_t i = 0; i < strlen(str); i++) {
		if(str[i] == expectedDelimiter) {
			handleDelimiter(tmp);	
		} else if(str[i] == otherDelimiter) {
			cerr << "WARNING: Unexpected delimiter while parsing" << endl;
		} else {
			if(tmp.length() > 0 && (str[i] == parameterDelimiter || isWhitespace(str[i]))) {
				trimString(tmp);
				params.push_back(tmp);
				tmp.clear();
			} else {
				tmp += str[i];
			}
		}
	}
		
	if (tmp.length() > 0) {
		//cerr << "WARNING: Reached end of line while parsing" << endl;
		handleDelimiter(tmp);
	}
}
示例#24
0
bool Spectators::check(const std::string& _password)
{
	if(password.empty())
		return true;

	std::string t = _password;
	return trimString(t) == password;
}
示例#25
0
void trie(FILE *pool,FILE *check,FILE *result) {
	clock_t start,end,start1;
	start = clock();
	TRIE *head = trie_create();
	char line[BUFFERSIZE];
	int count=0;
	int i=0;
	int exitflag=0;
	while(fgets(line,BUFFERSIZE,pool)) {
		/*delete the useless character '\r'*/
		exitflag = trimString(line);
		if(!exitflag){
			reverseString(line);
			trie_add(&head,line);	
		//	if(!(++count%100000)){ 
		//		end = clock();
		//		printf("%d,%f \n",count++,(double)(end -start)/CLOCKS_PER_SEC);
		//	} 
		}else{
			/*printf("Error email %s",line);*/
			continue;
		}
	}
	//end = clock();
	//printf("Creating tree using %f\n",(double)(end -start)/CLOCKS_PER_SEC);
	start1 = clock();
	while(fgets(line,BUFFERSIZE,check)) {

		i = 0;
		while(line[i]!='\r' && line[i]!='\n') i++;
		line[i] = '\0';
		exitflag = trimString(line);
		if(!exitflag){
			reverseString(line);
			if(trie_check(&head,line)) {
				fprintf(result,"yes\n");
			}else {
				fprintf(result,"no\n");
			}
		}
	}
	trie_destroy(&head);
	end = clock();
	printf("%f\n",(double)(end -start)/CLOCKS_PER_SEC);

}
示例#26
0
std::vector<bool> StringTools::stringVectorToBoolVector(std::vector<std::string> inputStringVector)
{
	std::vector<bool> result;
	std::string tmpString;

	for(std::vector<std::string>::iterator currentStringVectorEntry = inputStringVector.begin(); currentStringVectorEntry < inputStringVector.end(); ++currentStringVectorEntry)
	{
		trimString( *currentStringVectorEntry );
		tmpString.clear();
		tmpString = *currentStringVectorEntry;
		trimString(tmpString);

		result.push_back( stringToBool(tmpString) );
	}

	return result;
}
示例#27
0
文件: before.cpp 项目: epronk/gnocchi
 static std::string getFormattedName(std::string givenName, std::string middleName,
                                           std::string surname) {
        if (givenName.empty()) {
            givenName = trimString(givenName);
        } else {
            givenName = "";
        }
        if (middleName.empty()) {
            middleName = trimString(middleName);
        } else {
            middleName = "";
        }
        if (surname.empty()) {
            surname = trimString(surname);
        } else {
            surname = "";
        }
        return givenName + " " + middleName + " " + surname;
    }
示例#28
0
void addOldToTree(AllData& alldata, std::ostringstream& old_filter) {
	vector<string> pathes;

	if( !alldata.params.dispersion.filter_file_name.empty())
	{
        string filter_file_name = alldata.params.dispersion.filter_file_name;
        ifstream b_file(filter_file_name.c_str());
        if (b_file.good()) {
            string line;
            while (std::getline(b_file, line)) {
                trimString(line);
                if (line.substr(0, 1) != "#" && line.find_first_of("--")
                        != line.npos) {
                    pathes.push_back(line);
                } else {
                    if (line != STARTTEXT && line != STARTTEXT2 && line
                            != STARTTEXT3)
                        old_filter << line << endl;
                }
            }
            b_file.close();
        }

        while (!pathes.empty()) {
            string path = pathes.back();
            string tmp_path = path;
            pathes.pop_back();
            int pos = path.find_last_of("--") - 1;
            string tail = path.substr(pos, path.length() - pos);
            path = path.substr(0, pos);
            trimString(path);
            trimString(tail);
            string func = path.substr(path.find_last_of(";") + 1, path.length()
                    - (path.find_last_of(";") + 1));
            if (tail.find("C") != tail.npos && tail.find(" 0 ") != tail.npos) {
                parsePath(alldata, path, FILTEROUT);
            } else {
                old_filter << tmp_path << endl;
            }
        }
	}
}
示例#29
0
std::string Fragment::cleanFragment() const {
   static std::vector< std::string > const starts { BLOCK_START_TOKEN, VAR_START_TOKEN };
   if( std::find( starts.begin(),
          starts.end(), m_rawText.substr( 0, 2 ) ) != starts.end() ) {
      std::string result;
      std::copy( m_rawText.begin() + 2, m_rawText.end() - 2, std::back_inserter( result ) );
      trimString( result );
      return result;
   }
   return m_rawText;
}
示例#30
0
std::string parseNextParam(Tokenizer::iterator& it, Tokenizer::iterator end)
{
	std::string tmp;
	if (it == end) {
		return tmp;
	}

	tmp = *it++;
	trimString(tmp);
	return tmp;
}