// search for a key in the right_pos-sorted list with value less // than begin_key: pos_t htype_buffer:: leftmost_rightkey_pos(const pos_t& begin_range_pos, const pos_t& end_range_pos) const { typedef rightkey_t::const_iterator riter; pos_t begin_pos(end_range_pos); riter ri(_rightpos.lower_bound(begin_range_pos)); const riter ri_end(_rightpos.lower_bound(end_range_pos)); for (; ri!=ri_end; ++ri) begin_pos=std::min(begin_pos,ri->second); return begin_pos; }
void graphic_ui::create_the_animation_objects() { if(movements_info.size()) { for(auto& elem:movements_info) { sf::Vector2f begin_pos(elem.x_from*x_s,elem.y_from*y_s), end_pos(elem.x_to*x_s,elem.y_to*y_s); sf::Texture grid_movement_texture; grid_movement_texture.create(x_s,y_s); sf::Uint32 pixel=(0xff<<24)|//Assuming a little endian machine.. from RGBA to ABGR :| ((sf::Uint32)num_colors[elem.num].b<<16)| ((sf::Uint32)num_colors[elem.num].g<<8)| ((sf::Uint32)num_colors[elem.num].r); std::vector<sf::Uint32> pixel_map(x_s*y_s,pixel); grid_movement_texture.update((sf::Uint8*)&pixel_map.front()); sf::Sprite obj_sprite(grid_movement_texture); animation_engine::anim_texture_ptr object=animation_engine::animated_texture::create(obj_sprite); object->set_begin_position(begin_pos); object->set_end_position(end_pos); object->prepare_to_render(); object->set_animation_duration(0.07); anim_engine->register_object(object,animation_engine::animated_obj_completion_opt::ACTION_DONT_MOVE); //Add the text std::stringstream text_ss; text_ss<<elem.num; sf::Text text(text_ss.str().c_str(),font,52); text.setColor(sf::Color::Black); text.setStyle(sf::Text::Bold); animation_engine::anim_text_ptr object_text=animation_engine::animated_text::create(text); //Set the proper offset int x_offset=x_s/2-text.getCharacterSize()*text_ss.str().size()/4, y_offset=y_s/2-text.getCharacterSize()/2; begin_pos.x+=x_offset; begin_pos.y+=y_offset; end_pos.x+=x_offset; end_pos.y+=y_offset; object_text->set_begin_position(begin_pos); object_text->set_end_position(end_pos); object_text->prepare_to_render(); object_text->set_animation_duration(0.07); anim_engine->register_object(object_text,animation_engine::animated_obj_completion_opt::ACTION_DONT_MOVE); } movements_info.clear(); draw_movement=true; } else draw_movement=false; }
/*! * @if jp * @brief 文字列を分割文字で分割する * @else * @brief Split string by delimiter * @endif */ vstring split(const std::string& input, const std::string& delimiter, bool ignore_empty) { typedef std::string::size_type size; vstring results; size delim_size = delimiter.size(); size found_pos(0), begin_pos(0), pre_pos(0), substr_size(0); if (input.empty()) return results; // if (input.substr(0, delim_size) == delimiter) // begin_pos = pre_pos = delim_size; while (1) { // REFIND: found_pos = input.find(delimiter, begin_pos); if (found_pos == std::string::npos) { std::string substr(input.substr(pre_pos)); eraseHeadBlank(substr); eraseTailBlank(substr); if (!(substr.empty() && ignore_empty)) results.push_back(substr); break; } /* if (isEscaped(input, found_pos)) { begin_pos = found_pos + delim_size; goto REFIND; } */ substr_size = found_pos - pre_pos; if (substr_size >= 0) { std::string substr(input.substr(pre_pos, substr_size)); eraseHeadBlank(substr); eraseTailBlank(substr); if (!(substr.empty() && ignore_empty)) results.push_back(substr); } begin_pos = found_pos + delim_size; pre_pos = found_pos + delim_size; } return results; }
void wxHtmlParser::DoParsing(const wxString::const_iterator& begin_pos_, const wxString::const_iterator& end_pos) { wxString::const_iterator begin_pos(begin_pos_); if (end_pos <= begin_pos) return; wxHtmlTextPieces& pieces = *m_TextPieces; size_t piecesCnt = pieces.size(); while (begin_pos < end_pos) { while (m_CurTag && m_CurTag->GetBeginIter() < begin_pos) m_CurTag = m_CurTag->GetNextTag(); while (m_CurTextPiece < piecesCnt && pieces[m_CurTextPiece].m_start < begin_pos) m_CurTextPiece++; if (m_CurTextPiece < piecesCnt && (!m_CurTag || pieces[m_CurTextPiece].m_start < m_CurTag->GetBeginIter())) { // Add text: AddText(GetEntitiesParser()->Parse( wxString(pieces[m_CurTextPiece].m_start, pieces[m_CurTextPiece].m_end))); begin_pos = pieces[m_CurTextPiece].m_end; m_CurTextPiece++; } else if (m_CurTag) { if (m_CurTag->HasEnding()) begin_pos = m_CurTag->GetEndIter2(); else begin_pos = m_CurTag->GetBeginIter(); wxHtmlTag *t = m_CurTag; m_CurTag = m_CurTag->GetNextTag(); AddTag(*t); if (m_stopParsing) return; } else break; } }
/*! * @if jp * @brief 文字列の分割 * @else * @brief Split of string * @endif */ unsigned int CorbaNaming::split(const std::string& input, const std::string& delimiter, std::vector<std::string>& results) { typedef std::string::size_type size; size delim_size = delimiter.size(); size found_pos(0), begin_pos(0), pre_pos(0), substr_size(0); if (input.substr(0, delim_size) == delimiter) begin_pos = pre_pos = delim_size; while (1) { REFIND: found_pos = input.find(delimiter, begin_pos); if (found_pos == std::string::npos) { results.push_back(input.substr(pre_pos)); break; } if ('\\' == input.at(found_pos - 1)) { begin_pos = found_pos + delim_size; goto REFIND; } substr_size = found_pos - pre_pos; if (substr_size > 0) { results.push_back(input.substr(pre_pos, substr_size)); } begin_pos = found_pos + delim_size; pre_pos = found_pos + delim_size; } return results.size(); }
void wpl_struct::parse_value(wpl_namespace *ns) { char buf[WPL_VARNAME_SIZE]; wpl_matcher_position begin_pos(get_position()); ignore_string_match(WHITESPACE,0); if (parse_complete) { ignore_whitespace(); if (ignore_letter ('>')) { throw wpl_type_end_template_declaration(this); } try { get_word(buf); } catch (wpl_element_exception &e) { cerr << "After struct name '" << get_name() << "':\n"; throw; } throw wpl_type_begin_variable_declaration(this, buf, begin_pos); } /* TODO allow declaration only now and definition later */ if (!ignore_letter('{')) { THROW_ELEMENT_EXCEPTION("Expected block with declarations after struct declaration"); } if (ignore_letter ('}')) { goto no_members; } do { get_word(buf); wpl_parseable *parseable; if (!(parseable = ns->new_find_parseable(buf))) { load_position(begin_pos); cerr << "While parsing name '" << buf << "' inside struct:\n"; THROW_ELEMENT_EXCEPTION("Undefined name"); } parseable->load_position(get_position()); try { try { parseable->parse_value(this); } catch (wpl_type_begin_variable_declaration &e) { e.create_variable(this); load_position(parseable->get_position()); } } catch (wpl_type_begin_function_declaration &e) { e.parse_value(this); load_position(e.get_position()); } ignore_whitespace(); if (!ignore_letter (';')) { THROW_ELEMENT_EXCEPTION("Expected ';' after definition in struct"); } ignore_whitespace(); if (ignore_letter ('}')) { break; } } while (!at_end()); no_members: parse_complete = true; throw wpl_type_end_statement(get_position()); }
void wxHtmlParser::DoParsing(const wxString::const_iterator& begin_pos_, const wxString::const_iterator& end_pos) { wxString::const_iterator begin_pos(begin_pos_); if (end_pos <= begin_pos) return; wxHtmlTextPieces& pieces = *m_TextPieces; size_t piecesCnt = pieces.size(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while (begin_pos < end_pos) { #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while (m_CurTag && m_CurTag->GetBeginIter() < begin_pos) m_CurTag = m_CurTag->GetNextTag(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while (m_CurTextPiece < piecesCnt && pieces[m_CurTextPiece].m_start < begin_pos) m_CurTextPiece++; if (m_CurTextPiece < piecesCnt && (!m_CurTag || pieces[m_CurTextPiece].m_start < m_CurTag->GetBeginIter())) { // Add text: AddText(GetEntitiesParser()->Parse( wxString(pieces[m_CurTextPiece].m_start, pieces[m_CurTextPiece].m_end))); begin_pos = pieces[m_CurTextPiece].m_end; m_CurTextPiece++; } else if (m_CurTag) { if (m_CurTag->HasEnding()) begin_pos = m_CurTag->GetEndIter2(); else begin_pos = m_CurTag->GetBeginIter(); wxHtmlTag *t = m_CurTag; m_CurTag = m_CurTag->GetNextTag(); AddTag(*t); if (m_stopParsing) return; } else break; } }