std::vector<std::pair<boost::string_ref, boost::string_ref>>::const_iterator find(const boost::string_ref key) const { return std::find_if(m_collection.begin(), m_collection.end(), [key](const std::pair<boost::string_ref, boost::string_ref>& str)-> bool { auto oneSize = str.first.size(); auto twoSize = key.size(); if (oneSize != twoSize) { return false; } if (oneSize >= 4) { if ((str.first[0] == key[0]) && (str.first[1] == key[1]) && (str.first[oneSize - 1] == key[oneSize - 1]) && (str.first[oneSize - 2] == key[oneSize - 2])) { return std::memcmp(str.first.begin(), key.begin(), oneSize) == 0; } } else { return std::memcmp(str.first.begin(), key.begin(), oneSize) == 0; } return false; } ); }
bool operator()(const boost::string_ref& strRef1, const boost::string_ref& strRef2) const { auto oneSize = strRef1.size(); auto twoSize = strRef2.size(); if (oneSize != twoSize) { return false; } return std::memcmp(strRef1.begin(), strRef2.begin(), oneSize) == 0; }
void print_string(boost::string_ref str, std::ostream& out) { for (boost::string_ref::const_iterator cur = str.begin(); cur != str.end(); ++cur) { print_char(*cur, out); } }
std::string codegen_base::cpp_name(boost::string_ref name) { std::string result; if (!std::isalpha(name[0])) result = "_"; std::transform(name.begin(), name.end(), std::back_inserter(result), [] (char c) { return std::isalnum(c) ? c : '_'; }); return result; }
inline bool is_emm_file(boost::string_ref path) { std::ifstream ifs( convert_code( path, CP_UTF8, CP_OEMCP ), std::ios::binary ); if( ifs.fail() ) { return false; } std::istreambuf_iterator< char > first( ifs ), last; boost::string_ref const seg( "[Info]\r\nVersion = 3\r\n" ); return std::search( first, last, seg.begin(), seg.end() ) != last; }
inline bool drive_letter_exists(Iterator itr, Iterator end) { boost::string_ref const str( ":\\" ); if( std::distance( itr, end ) < static_cast< std::ptrdiff_t >( str.size() + 1 ) ) { return false; } for( int i = 'A'; i <= 'Z'; ++i ) { if( *itr == i ) { return std::equal( str.begin(), str.end(), itr + 1 ); } } return false; }
id_placeholder::id_placeholder( unsigned index, boost::string_ref id, id_category category, id_placeholder const* parent_) : index(index), unresolved_id(parent_ ? parent_->unresolved_id + '.' + detail::to_s(id) : detail::to_s(id)), id(id.begin(), id.end()), parent(parent_), category(category), num_dots(boost::range::count(id, '.') + (parent_ ? parent_->num_dots + 1 : 0)) { }
std::string encode_string(boost::string_ref str) { std::string result; result.reserve(str.size()); for (boost::string_ref::const_iterator it = str.begin(); it != str.end(); ++it) { switch (*it) { case '<': result += "<"; break; case '>': result += ">"; break; case '&': result += "&"; break; case '"': result += """; break; default: result += *it; break; } } return result; }
file(file const& f, boost::string_ref source) : path(f.path), source_(source.begin(), source.end()), is_code_snippets(f.is_code_snippets), qbk_version(f.qbk_version), ref_count(0) {}
auto operator()(boost::string_ref string) const { return boost::hash_range(string.begin(), string.end()); }
size_t operator()(const boost::string_ref& strRef) const { return boost::hash_range(strRef.begin(), strRef.end()); }
inline std::string to_s(boost::string_ref x) { return std::string(x.begin(), x.end()); }
inline std::string escape_uri(boost::string_ref uri) { return escape_uri(std::string(uri.begin(), uri.end())); }
url:: url(const boost::string_ref &ref) : m_string { ref.begin(), ref.end() } { parse(); }
file(fs::path const& path, boost::string_ref source, unsigned qbk_version) : path(path), source_(source.begin(), source.end()), is_code_snippets(false), qbk_version(qbk_version), ref_count(0) {}
fs::path generic_to_path(boost::string_ref x) { return fs::path(x.begin(), x.end()); }
void syntax_highlight_actions::callout(parse_iterator, parse_iterator) { out << state.add_callout(qbk_value(state.current_file, marked_text.begin(), marked_text.end())); marked_text.clear(); }