예제 #1
0
void parsePassword(const Common::UString &arg, std::vector<byte> &password) {
    const size_t length = arg.size();

    password.clear();
    password.reserve(length / 2);

    size_t i = 0;
    byte c = 0x00;
    for (Common::UString::iterator s = arg.begin(); s != arg.end(); ++s, i++) {
        byte d = 0;

        if      (*s >= '0' && *s <= '9')
            d = *s - '0';
        else if (*s >= 'a' && *s <= 'f')
            d = *s - 'a' + 10;
        else if (*s >= 'A' && *s <= 'F')
            d = *s - 'A' + 10;
        else
            throw Common::Exception("0x%08X is not a valid hex digit", (uint) *s);

        if ((i % 2) == 1) {
            c |= d;

            password.push_back(c);

            c = 0x00;
        } else
            c |= d << 4;
    }
}
예제 #2
0
파일: console.cpp 프로젝트: EffWun/xoreos
uint32 ConsoleWindow::findWordStart(const Common::UString &line, uint32 pos) {
	Common::UString::iterator it = line.getPosition(pos);
	if ((it == line.end()) || (*it == ' '))
		return 0;

	while ((it != line.begin()) && (*it != ' '))
		--it;

	if (*it == ' ')
		++it;

	return line.getPosition(it);
}
예제 #3
0
파일: util.cpp 프로젝트: TC01/phaethon
Common::UString FileTypeManager::getExtension(FileType type) {
	buildTypeLookup();

	Common::UString ext;
	TypeLookup::const_iterator t = _typeLookup.find(type);
	if (t != _typeLookup.end())
		ext = t->second->extension;

	if (ext.beginsWith("."))
		ext.erase(ext.begin());

	return ext;
}
예제 #4
0
파일: area.cpp 프로젝트: clone2727/xoreos
// "Elfland: The Woods" -> "The Woods"
Common::UString Area::createDisplayName(const Common::UString &name) {
	for (Common::UString::iterator it = name.begin(); it != name.end(); ++it) {
		if (*it == ':') {
			if (++it == name.end())
				break;

			if (*it == ' ')
				if (++it == name.end())
					break;

			return Common::UString(it, name.end());
		}
	}

	return name;
}
예제 #5
0
static bool parseOption(const Common::UString &arg, Common::UString &key) {
	if (arg.size() < 2) {
		warning("Unrecognized command line argument \"%s\"", arg.c_str());
		return false;
	}

	Common::UString::iterator start = arg.begin();
	++start;

	Common::UString value;
	if (*start == '-') {
		// Long option

		++start;

		Common::UString::iterator e = arg.findFirst('=');
		if (e != arg.end()) {
			key = arg.substr(start, e++);
			value = arg.substr(e, arg.end());
		} else
			key = arg.substr(start, arg.end());

	} else {
		// Short option

		key   = convertShortToLongOption(*start++);
		value = arg.substr(start, arg.end());
	}

	if (key.empty()) {
		warning("Unrecognized command line argument \"%s\"", arg.c_str());
		return false;
	}

	if (value.empty())
		return true;

	if (!setOption(key, value))
		return false;

	return true;
}
예제 #6
0
파일: util.cpp 프로젝트: Glyth/xoreos
Common::UString createDisplayName(const Common::UString &name) {
	bool inBrace = false;

	Common::UString displayName;
	for (Common::UString::iterator it = name.begin(); it != name.end(); ++it) {
		if (*it == '{') {
			inBrace = true;
			continue;
		}

		if (*it == '}') {
			inBrace = false;
			continue;
		}

		if (!inBrace)
			displayName += *it;
	}

	return displayName;
}
예제 #7
0
Common::UString XMLWriter::escape(const Common::UString &str) {
	Common::UString escaped;

	for (Common::UString::iterator s = str.begin(); s != str.end(); ++s) {
		uint32 c = *s;

		if      (c == '\"')
			escaped += "&quot;";
		else if (c == '\'')
			escaped += "&apos;";
		else if (c == '&')
			escaped += "&amp;";
		else if (c == '<')
			escaped += "&lt;";
		else if (c == '>')
			escaped += "&gt;";
		else
			escaped += c;

	}

	return escaped;
}
예제 #8
0
파일: text.cpp 프로젝트: farmboy0/xoreos
void Text::drawLine(const Common::UString &line,
                    ColorPositions::const_iterator color, size_t position) {

	Font &font = _font.getFont();

	// Horizontal Align
	glTranslatef(roundf((_width - font.getLineWidth(line)) * _halign), 0.0f, 0.0f);

	// Draw line
	for (Common::UString::iterator s = line.begin(); s != line.end(); ++s, position++) {
		// If we have color changes, apply them
		while ((color != _colors.end()) && (color->position <= position)) {
			if (color->defaultColor)
				glColor4f(_r, _g, _b, _a);
			else
				glColor4f(color->r, color->g, color->b, color->a);

			++color;
		}

		font.draw(*s);
	}
}
예제 #9
0
파일: ttffont.cpp 프로젝트: cc9cii/xoreos
void TTFFont::buildChars(const Common::UString &str) {
	for (Common::UString::iterator c = str.begin(); c != str.end(); ++c)
		addChar(*c);

	rebuildPages();
}