Пример #1
0
 void reset()
 {
   state.clear();
   p = 0.;
   has_progress  = false;
   abortable = false;
   is_aborted  = false;
 }
Пример #2
0
    /* compressed utf-8 table */
        0x20ac, /* 80 Euro. CP1252 from here on... */
        0x81,   /* 81 NA */
        0x201a, /* 82 */
        0x192,  /* 83 */
        0x201e, /* 84 */
        0x2026, /* 85 */
        0x2020, /* 86 */
        0x2021, /* 87 */
        0x2c6,  /* 88 */
        0x2030, /* 89 */
        0x160,  /* 8a */
        0x2039, /* 8b */
        0x152,  /* 8c */
        0x8d,   /* 8d NA */
        0x17d,  /* 8e */
        0x8f,   /* 8f NA */
        0x90,   /* 90 NA */
        0x2018, /* 91 */
        0x2019, /* 92 */
        0x201c, /* 93 */
        0x201d, /* 94 */
        0x2022, /* 95 */
        0x2013, /* 96 */
        0x2014, /* 97 */
        0x2dc,  /* 98 */
        0x2122, /* 99 */
        0x161,  /* 9a */
        0x203a, /* 9b */
        0x153,  /* 9c */
        0x9d,   /* 9d NA */
        0x17e,  /* 9e */
        0x178,  /* 9f */
        0xa0,   /* a0 */
        0xa1,   /* a1 */
        0xa2,   /* a2 */
        0xa3,   /* a3 */
        0x20ac  /* a4 ISO-8859-15 Euro. */
    };

    while (len) {
        if (G_UNLIKELY(*text >= 0x80) && G_UNLIKELY(*text <= 0xa4)) {
            int idx = *text - 0x80;
            output += lowtable[idx];
        } else {
            output += (gunichar)*text;    /* ascii/iso88591 maps directly */
        }

        text++;
        len--;
    }
    return output;
}/*}}}*/
void set_charset(Glib::ustring charset) {/*{{{*/
    charset = charset.uppercase();

    if (charset.find(' ') != Glib::ustring::npos)
        charset = charset.erase(charset.find(' '));

    if (charset.empty() || !charset.compare("SYSTEM")) {
        charset.clear();
    } else {
        try {
            Glib::IConv test("UTF-8", charset);
        } catch (...) {
            fprintf(stderr, "Charset '%s' isn't supported by your system - using system locale\n", charset.c_str());
            charset.clear();
        }
    }

    serverCharset = charset;
}/*}}}*/
Пример #3
0
void StreamReader::read_to_end(Glib::ustring & text)
{
  DBG_ASSERT(m_file, "file is NULL");

  text.clear();

  char buffer[READ_BUFFER_COUNT + 1]; // +1 for the NUL terminate.
  size_t byte_read = 0;
  do {
    byte_read = fread(buffer, 1, READ_BUFFER_COUNT, m_file);
    buffer[byte_read+1] = 0; // NUL terminate.
    text += buffer;
  }
  while(byte_read == READ_BUFFER_COUNT);
}
Пример #4
0
Glib::ustring TextPatternEntity::parsePattern(void)
{
	Glib::ustring text;
	Glib::ustring next;
	Token token;

	m_parser.reset();
	while (m_parser.hasMoreTokens())
	{
		// Copiamos los delimitadores encontrados
		text += m_parser.lastDelimiterString();
		token = m_parser.nextToken();
		next = token.string;

		// Comprobamos si hay que procesar la plataforma
		if (token.string.find("%p_", 0) == 0)
		{
			// Como es un patrón, inicialmente lo limpiamos para no poner patrones inválidos
			next.clear();
			if (m_platform)
			{
				switch (token.type)
				{
				case TK_P_TITLE:
					next = m_platform->getTitle();
					break;
				case TK_P_MANUFACTURER:
					next = m_platform->getManufacturer();
					break;
				case TK_P_YEAR:
					next = m_platform->getYear();
					break;
				case TK_P_LISTS_COUNT:
					next = utils::toStr(m_platform->gamelistCount());
					break;
				case TK_P_GAMES_COUNT:
					next = utils::toStr(m_platform->gamelistGet()->gameCount());
					break;
				}
			}
		}
		// Comprobamos si hay que procesar la lista de juegos
		if (token.string.find("%l_", 0) == 0)
		{
			next.clear();
			if (m_gamelist)
			{
				switch (token.type)
				{
				case TK_L_NAME:
					next = m_gamelist->getName().empty() ? _("Master") : m_gamelist->getName();
					break;
				case TK_L_FILTERED:
					next = m_gamelist->isFiltered() ? _("Yes") : _("Not");
					break;
				case TK_L_GAMES_COUNT:
					next = utils::toStr(m_gamelist->gameCount());
					break;
				case TK_L_FILTERED_COUNT:
					next = utils::toStr(m_gamelist->gameCountFiltered());
					break;
				}
			}
		}
		// Comprobamos si hay que procesar el juego
		if (token.string.find("%g_", 0) == 0)
		{
			next.clear();
			if (m_game)
			{
				switch (token.type)
				{
				case TK_G_NAME:
					next = m_game->name;
					break;
				case TK_G_TITLE:
					next = m_game->title;
					break;
				case TK_G_CLONEOF:
					next = m_game->cloneof;
					break;
				case TK_G_MANUFACTURER:
					next = m_game->manufacturer;
					break;
				case TK_G_YEAR:
					next = m_game->year;
					break;
				case TK_G_GENRE:
					next = m_game->genre;
					break;
				case TK_G_PLAYERS:
					next = utils::toStr(m_game->players);
					break;
				case TK_G_PLAYERS_SIMULTANEOUS:
					next = m_game->simultaneous ? _("Yes") : _("Not");
					break;
				case TK_G_RATING:
					next = utils::toStr(m_game->rating);
					break;
				case TK_G_TIMES_PLAYED:
					next = utils::toStr(m_game->times_played);
					break;
				case TK_G_FAVORITE:
					next = m_game->favorite ? _("Yes") : _("Not");
					break;
				}
			}
		}
		if (token.string.find("%m_", 0) == 0)
		{
			next.clear();
			switch (token.type)
			{
			case TK_M_DATE:
				next = m_date;
				break;
			case TK_M_TIME:
				next = m_time;
				break;
			}
		}
		text += next;
	}
	// Copiamos los delimitadores finales si hubieran
	text += m_parser.lastDelimiterString();
	return text;
}