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


C++ StringRange::ToString方法代码示例

本文整理汇总了C++中StringRange::ToString方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRange::ToString方法的具体用法?C++ StringRange::ToString怎么用?C++ StringRange::ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringRange的用法示例。


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

示例1: normalise_path

	static void normalise_path(std::string &result, const StringRange &path)
	{
		StringRange part(path.begin, path.end);
		if (!path.Empty() && (path[0] == '/')) {
			result += '/';
			++part.begin;
		}
		const size_t initial_result_length = result.size();
		while (true) {
			part.end = part.FindChar('/'); // returns part.end if the char is not found
			if (part.Empty() || (part == ".")) {
				// skip this part
			} else if (part == "..") {
				// pop the last component
				if (result.size() <= initial_result_length)
					throw std::invalid_argument(path.ToString());
				size_t pos = result.rfind('/');
				if (pos == std::string::npos) { pos = 0; }
				assert(pos >= initial_result_length);
				result.erase(pos);
			} else {
				// push the new component
				if (result.size() > initial_result_length)
					result += '/';
				result.append(part.begin, part.Size());
			}
			if (part.end == path.end) { break; }
			assert(*part.end == '/');
			part.begin = part.end + 1;
			part.end = path.end;
		}
	}
开发者ID:HeadHunterEG,项目名称:pioneer,代码行数:32,代码来源:FileSystem.cpp

示例2: ParseInfo

void DistanceFieldFont::ParseInfo(const StringRange &line)
{
	std::stringstream ss(line.ToString());
	std::string token;

	while (ss >> token != 0) {
		std::pair<std::string, std::string> pair;
		split_token(token, pair);
		if (pair.first == "size") {
			m_fontSize = get_value<float>(pair.second);
			return;
		}
	}
}
开发者ID:Metamartian,项目名称:pioneer,代码行数:14,代码来源:DistanceFieldFont.cpp

示例3: ParseCommon

void DistanceFieldFont::ParseCommon(const StringRange &line)
{
	std::stringstream ss(line.ToString());
	std::string token;

	while (ss >> token != 0) {
		std::pair<std::string, std::string> pair;
		split_token(token, pair);
		if (pair.first == "scaleW")
			m_sheetSize.x = get_value<float>(pair.second);
		else if (pair.first == "scaleH")
			m_sheetSize.y = get_value<float>(pair.second);
	}
}
开发者ID:Metamartian,项目名称:pioneer,代码行数:14,代码来源:DistanceFieldFont.cpp

示例4: ParseChar

//get font definitions from a line of xml, insert glyph information into the map
void DistanceFieldFont::ParseChar(const StringRange &r)
{
	std::stringstream ss(r.ToString());
	std::string token;

	Uint32 id = 0;
	double x = 0.0;
	double y = 0.0;
	double uSize = 0.0;
	double vSize = 0.0;
	double xoffset = 0.0;
	double yoffset = 0.0;
	double advance = 0.0;

	while (ss >> token) {
			std::pair<std::string, std::string> pair;
			split_token(token, pair);

			//only care about some values
			if (pair.first == "id")
				id = get_value<Uint32>(pair.second);
			else if (pair.first == "x")
				x = get_value<double>(pair.second);
			else if (pair.first == "y")
				y = get_value<double>(pair.second);
			else if (pair.first == "width")
				uSize = get_value<double>(pair.second);
			else if (pair.first == "height")
				vSize = get_value<double>(pair.second);
			else if (pair.first == "xoffset")
				xoffset = get_value<float>(pair.second);
			else if (pair.first == "yoffset")
				yoffset = get_value<float>(pair.second);
			else if (pair.first == "xadvance")
				advance = get_value<float>(pair.second);
	}

	const float scale = 1.f/m_fontSize;
	Glyph g;
	g.uv = vector2f(float(x)/m_sheetSize.x, float(y)/m_sheetSize.y);
	g.uvSize = vector2f(float(uSize)/m_sheetSize.x, float(vSize)/m_sheetSize.y);
	g.size = vector2f(float(uSize), float(vSize)) * scale;
	g.offset = vector2f(float(xoffset), float(m_lineHeight-vSize-yoffset)) * scale;
	g.xAdvance = advance * scale;
	m_glyphs[id] = g;
}
开发者ID:AmesianX,项目名称:pioneer,代码行数:47,代码来源:DistanceFieldFont.cpp

示例5: Read

void IniConfig::Read(const FileSystem::FileData &data)
{
	StringRange buffer = data.AsStringRange();
	buffer = buffer.StripUTF8BOM();

	std::string section_name;
	MapType *section_map = 0;

	while (!buffer.Empty()) {
		StringRange line = buffer.ReadLine().StripSpace();

		// if the line is a comment, skip it
		if (line.Empty() || (line[0] == '#')) continue;

		// check for a section header
		if ((line.Size() >= 2) && (line[0] == '[') && (line.end[-1] == ']')) {
			++line.begin;
			--line.end;
			section_name = line.ToString();
			section_map = 0;
			continue;
		}

		const char *kend = line.FindChar('=');
		// if there's no '=' sign, skip the line
		if (kend == line.end) {
			Output("WARNING: ignoring invalid line in config file:\n   '%.*s'\n", int(line.Size()), line.begin);
			continue;
		}

		StringRange key(line.begin, kend);
		StringRange value(kend + 1, line.end);
		// strip whitespace
		key.end = key.RFindNonSpace();
		value = value.StripSpace();

		if (!section_map)
			section_map = &m_map[section_name];

		(*section_map)[key.ToString()] = value.ToString();
	}
}
开发者ID:Ikesters,项目名称:pioneer,代码行数:42,代码来源:IniConfig.cpp

示例6: normalise_path

static void normalise_path(std::string &result, const StringRange &path)
{
    StringRange part(path.begin, path.begin);
    const char *c = path.begin;
    if ((c != path.end) && (*c == '/')) {
        result += '/';
        ++c;
        ++part.begin;
    }
    const size_t initial_result_length = result.size();
    while (true) {
        if ((*c == '/') || (c == path.end)) {
            part.end = c;
            if (part.Empty() || (part == ".")) {
                // skip this part
            } else if (part == "..") {
                // pop the last component
                if (result.size() <= initial_result_length)
                    throw std::invalid_argument(path.ToString());
                size_t pos = result.rfind('/', result.size()-2);
                ++pos;
                assert(pos >= initial_result_length);
                result.erase(pos);
            } else {
                // push the new component
                if (part.end != path.end) {
                    assert(*part.end == '/');
                    ++part.end;
                }
                result.append(part.begin, part.Size());
            }
            part.begin = c+1;
        }
        if (c == path.end) {
            break;
        }
        ++c;
    }
}
开发者ID:GizmoR13,项目名称:pioneer,代码行数:39,代码来源:FileSystem.cpp


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