Exemple #1
0
            inline static void split(std::vector<std::string>& mTarget,
                const std::string& mStr,
                const std::vector<std::string>& mSeparator)
            {
                StrSize pos{0}, startAt{0}, lastLength;
                std::string token;
                while((pos = findFirstOf(mStr, startAt, mSeparator,
                           lastLength)) != std::string::npos)
                {
                    auto tokenLength(pos - startAt);

                    // If we need to keep the separator in the splitted strings,
                    // add
                    // the separator's length to the token length
                    if(TM == Split::TrailingSeparator)
                        tokenLength += lastLength;

                    token = mStr.substr(startAt, tokenLength);
                    if(!token.empty()) mTarget.emplace_back(token);
                    if(TM == Split::TokenizeSeparator)
                        mTarget.emplace_back(mStr, pos, lastLength);
                    startAt = pos + lastLength;
                }

                std::string reimaining(
                    mStr.substr(startAt, mStr.size() - startAt));
                if(!reimaining.empty()) mTarget.emplace_back(reimaining);
            }
Exemple #2
0
bool cFixedAlloc::getFrame(uint32_t frame) {
	//Find first free
	uint32_t firstFree = findFirstOf(false, frames);
	if ( !checkAvailable(firstFree) )
		return false;

	frames.set(firstFree);
	--openFrames;
	printFrames();

	return true;
}
Exemple #3
0
pair<bool,uint32_t> cFixedAlloc::getFrame() {
	//Find first free
	uint32_t firstFree = findFirstOf(false, frames);

	if ( !checkAvailable(firstFree) )
		return make_pair(false, 0);

	frames.set(firstFree);
	--openFrames;
	printFrames();

	return make_pair(true, firstFree);
}
Exemple #4
0
std::vector<std::string> split(std::string const& str, const std::string* sep, size_t n)
{
	std::vector<std::string> list;
	size_t i = 0;
	size_t found = std::string::npos;
	size_t seplen = std::string::npos;
	while((findFirstOf(str, sep, n, i, &found, &seplen)) != std::string::npos){
		if(found != i){
			list.push_back(str.substr(i, found-i));
		}
		i = found+seplen;
	}
	if(i != str.size()){
		list.push_back(str.substr(i));
	}
	return list;
}
Exemple #5
0
//
// ANSI C functionality
//
int String::findFirstOf(const String& s, size_t& fpos, size_t pos) const
{
    return findFirstOf(s.getStr(), fpos, pos, s.length());
}