bool NameRecord::operator==(const NameRecord &o) { if (isNull() != o.isNull() || owner() != o.owner() || ttl() != o.ttl() || type() != o.type()) { return false; } switch (type()) { case XMPP::NameRecord::A: case XMPP::NameRecord::Aaaa: return address() == o.address(); case XMPP::NameRecord::Mx: return name() == o.name() && priority() == o.priority(); case XMPP::NameRecord::Srv: return name() == o.name() && port() == o.port() && priority() == o.priority() && weight() == o.weight(); case XMPP::NameRecord::Cname: case XMPP::NameRecord::Ptr: case XMPP::NameRecord::Ns: return name() == o.name(); case XMPP::NameRecord::Txt: return texts() == o.texts(); case XMPP::NameRecord::Hinfo: return cpu() == o.cpu() && os() == o.os(); case XMPP::NameRecord::Null: return rawData() == o.rawData(); case XMPP::NameRecord::Any: return false; } return false; }
// テキストの設定 void resultText::textSelect() { // スコアデータの取得 UserDefault *userDef = UserDefault::getInstance(); float tempScore = userDef->getIntegerForKey("Score", 0); int textRoot; score = tempScore; if (SCOREBORDER_1) { textRoot = 1; } else if (SCOREBORDER_2) { textRoot = 2; } else if (SCOREBORDER_3) { textRoot = 3; } else if (SCOREBORDER_4) { textRoot = 4; } else { textRoot = 5; } texts(textRoot); }
void TextManager::SetLanguage( const Ogre::String& language ) { m_Language = language; UnloadTexts(); XmlTextsFile texts( "./data/texts.xml" ); texts.LoadTexts(); }
bool BingoGame::crear_archivo_fichas(const char* callingcard_name, const char* texts_name) { std::string name(""); std::string texts(texts_name); name += texts.substr(0, texts.length() - 4); name += "-"; name += callingcard_name; std::ifstream game_texts_template; game_texts_template.open(callingcard_name); if ( ! game_texts_template ) { std::cerr << "toc: could not open document" << std::endl; return false; } std::ofstream user_card; user_card.open(name.c_str()); if ( ! user_card ) { std::cerr << "toc: could not create document" << std::endl; return false; } std::string line; int i = 0; while (! game_texts_template.eof()) { std::getline(game_texts_template, line); size_t pos = line.find("${"); if ( pos != std::string::npos ) { user_card << line.substr(0, pos) << words[i] << line.substr(pos + 9) << std::endl; ++i; } else { user_card << line << std::endl; } } game_texts_template.close(); user_card.close(); return true; }
void write_header( const View& view ) { using png_rw_info_t = detail::png_write_support < typename channel_type<typename get_pixel_type<View>::type>::type, typename color_space_type<View>::type >; // Set the image information here. Width and height are up to 2^31, // bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on // the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, // PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, // or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or // PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST // currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED png_set_IHDR( get_struct() , get_info() , static_cast< png_image_width::type >( view.width() ) , static_cast< png_image_height::type >( view.height() ) , static_cast< png_bitdepth::type >( png_rw_info_t::_bit_depth ) , static_cast< png_color_type::type >( png_rw_info_t::_color_type ) , _info._interlace_method , _info._compression_type , _info._filter_method ); #ifdef BOOST_GIL_IO_PNG_FLOATING_POINT_SUPPORTED if( _info._valid_cie_colors ) { png_set_cHRM( get_struct() , get_info() , _info._white_x , _info._white_y , _info._red_x , _info._red_y , _info._green_x , _info._green_y , _info._blue_x , _info._blue_y ); } if( _info._valid_file_gamma ) { png_set_gAMA( get_struct() , get_info() , _info._file_gamma ); } #else if( _info._valid_cie_colors ) { png_set_cHRM_fixed( get_struct() , get_info() , _info._white_x , _info._white_y , _info._red_x , _info._red_y , _info._green_x , _info._green_y , _info._blue_x , _info._blue_y ); } if( _info._valid_file_gamma ) { png_set_gAMA_fixed( get_struct() , get_info() , _info._file_gamma ); } #endif // BOOST_GIL_IO_PNG_FLOATING_POINT_SUPPORTED if( _info._valid_icc_profile ) { #if PNG_LIBPNG_VER_MINOR >= 5 png_set_iCCP( get_struct() , get_info() , const_cast< png_charp >( _info._icc_name.c_str() ) , _info._iccp_compression_type , reinterpret_cast< png_const_bytep >( & (_info._profile.front ()) ) , _info._profile_length ); #else png_set_iCCP( get_struct() , get_info() , const_cast< png_charp >( _info._icc_name.c_str() ) , _info._iccp_compression_type , const_cast< png_charp >( & (_info._profile.front()) ) , _info._profile_length ); #endif } if( _info._valid_intent ) { png_set_sRGB( get_struct() , get_info() , _info._intent ); } if( _info._valid_palette ) { png_set_PLTE( get_struct() , get_info() , const_cast< png_colorp >( &_info._palette.front() ) , _info._num_palette ); } if( _info._valid_background ) { png_set_bKGD( get_struct() , get_info() , const_cast< png_color_16p >( &_info._background ) ); } if( _info._valid_histogram ) { png_set_hIST( get_struct() , get_info() , const_cast< png_uint_16p >( &_info._histogram.front() ) ); } if( _info._valid_offset ) { png_set_oFFs( get_struct() , get_info() , _info._offset_x , _info._offset_y , _info._off_unit_type ); } if( _info._valid_pixel_calibration ) { std::vector< const char* > params( _info._num_params ); for( std::size_t i = 0; i < params.size(); ++i ) { params[i] = _info._params[ i ].c_str(); } png_set_pCAL( get_struct() , get_info() , const_cast< png_charp >( _info._purpose.c_str() ) , _info._X0 , _info._X1 , _info._cal_type , _info._num_params , const_cast< png_charp >( _info._units.c_str() ) , const_cast< png_charpp >( ¶ms.front() ) ); } if( _info._valid_resolution ) { png_set_pHYs( get_struct() , get_info() , _info._res_x , _info._res_y , _info._phy_unit_type ); } if( _info._valid_significant_bits ) { png_set_sBIT( get_struct() , get_info() , const_cast< png_color_8p >( &_info._sig_bits ) ); } #ifndef BOOST_GIL_IO_PNG_1_4_OR_LOWER #ifdef BOOST_GIL_IO_PNG_FLOATING_POINT_SUPPORTED if( _info._valid_scale_factors ) { png_set_sCAL( get_struct() , get_info() , this->_info._scale_unit , this->_info._scale_width , this->_info._scale_height ); } #else #ifdef BOOST_GIL_IO_PNG_FIXED_POINT_SUPPORTED if( _info._valid_scale_factors ) { png_set_sCAL_fixed( get_struct() , get_info() , this->_info._scale_unit , this->_info._scale_width , this->_info._scale_height ); } #else if( _info._valid_scale_factors ) { png_set_sCAL_s( get_struct() , get_info() , this->_info._scale_unit , const_cast< png_charp >( this->_info._scale_width.c_str() ) , const_cast< png_charp >( this->_info._scale_height.c_str() ) ); } #endif // BOOST_GIL_IO_PNG_FIXED_POINT_SUPPORTED #endif // BOOST_GIL_IO_PNG_FLOATING_POINT_SUPPORTED #endif // BOOST_GIL_IO_PNG_1_4_OR_LOWER if( _info._valid_text ) { std::vector< png_text > texts( _info._num_text ); for( std::size_t i = 0; i < texts.size(); ++i ) { png_text pt; pt.compression = _info._text[i]._compression; pt.key = const_cast< png_charp >( this->_info._text[i]._key.c_str() ); pt.text = const_cast< png_charp >( this->_info._text[i]._text.c_str() ); pt.text_length = _info._text[i]._text.length(); texts[i] = pt; } png_set_text( get_struct() , get_info() , &texts.front() , _info._num_text ); } if( _info._valid_modification_time ) { png_set_tIME( get_struct() , get_info() , const_cast< png_timep >( &_info._mod_time ) ); } if( _info._valid_transparency_factors ) { int sample_max = ( 1u << _info._bit_depth ); /* libpng doesn't reject a tRNS chunk with out-of-range samples */ if( !( ( _info._color_type == PNG_COLOR_TYPE_GRAY && (int) _info._trans_values[0].gray > sample_max ) || ( _info._color_type == PNG_COLOR_TYPE_RGB &&( (int) _info._trans_values[0].red > sample_max || (int) _info._trans_values[0].green > sample_max || (int) _info._trans_values[0].blue > sample_max ) ) ) ) { //@todo Fix that once reading transparency values works /* png_set_tRNS( get_struct() , get_info() , trans , num_trans , trans_values ); */ } } // Compression Levels - valid values are [0,9] png_set_compression_level( get_struct() , _info._compression_level ); png_set_compression_mem_level( get_struct() , _info._compression_mem_level ); png_set_compression_strategy( get_struct() , _info._compression_strategy ); png_set_compression_window_bits( get_struct() , _info._compression_window_bits ); png_set_compression_method( get_struct() , _info._compression_method ); png_set_compression_buffer_size( get_struct() , _info._compression_buffer_size ); #ifdef BOOST_GIL_IO_PNG_DITHERING_SUPPORTED // Dithering if( _info._set_dithering ) { png_set_dither( get_struct() , &_info._dithering_palette.front() , _info._dithering_num_palette , _info._dithering_maximum_colors , &_info._dithering_histogram.front() , _info._full_dither ); } #endif // BOOST_GIL_IO_PNG_DITHERING_SUPPORTED // Filter if( _info._set_filter ) { png_set_filter( get_struct() , 0 , _info._filter ); } // Invert Mono if( _info._invert_mono ) { png_set_invert_mono( get_struct() ); } // True Bits if( _info._set_true_bits ) { png_set_sBIT( get_struct() , get_info() , &_info._true_bits.front() ); } // sRGB Intent if( _info._set_srgb_intent ) { png_set_sRGB( get_struct() , get_info() , _info._srgb_intent ); } // Strip Alpha if( _info._strip_alpha ) { png_set_strip_alpha( get_struct() ); } // Swap Alpha if( _info._swap_alpha ) { png_set_swap_alpha( get_struct() ); } png_write_info( get_struct() , get_info() ); }
void ColumnPrinter::print(std::ostream& out) const { // stringstream::str() copies the string, so we need // to extract all the strings and store them to avoid copying // at every access. std::vector<std::string> texts(getColumnCount()); for (size_t col = 0; col < getColumnCount(); ++col) texts[col] = _cols[col]->text.str(); // Calculate the width of each column. std::vector<size_t> widths(getColumnCount()); for (size_t col = 0; col < getColumnCount(); ++col) { const auto& text = texts[col]; size_t maxWidth = 0; size_t pos = 0; while (pos < text.size()) { size_t width = getLineWidth(text, pos); if (width > maxWidth) maxWidth = width; // We can't just increment pos unconditionally by width + 1, as // that could result in an overflow. pos += width; if (pos == text.size()) break; if (text[pos] == '\0') { ++pos; if (pos == text.size()) break; ++pos; } else if (text[pos] == '\n') ++pos; } widths[col] = maxWidth; } // Print each row std::vector<size_t> poses(getColumnCount()); while (true) { bool done = true; for (size_t col = 0; col < getColumnCount(); ++col) { if (poses[col] < texts[col].size()) { done = false; break; } } if (done) break; out << _prefix; for (size_t col = 0; col < getColumnCount(); ++col) { out << _cols[col]->prefix; const std::string& text = texts[col]; size_t& pos = poses[col]; size_t width = getLineWidth(text, pos); char padChar = ' '; if ( pos + width < text.size() && text[pos + width] == '\0' && pos + width + 1 < text.size() ) { padChar = text[pos + width + 1]; } if (!_cols[col]->flushLeft) printChars(out, widths[col] - width, padChar); while (pos < text.size()) { if (text[pos] == '\n') { ++pos; break; } if (text[pos] == '\0') { ++pos; if (pos < text.size()) { MATHIC_ASSERT(text[pos] == padChar); ++pos; } break; } out << text[pos]; ++pos; } if (_cols[col]->flushLeft) printChars(out, widths[col] - width, padChar); out << _cols[col]->suffix; } out << '\n'; } }