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; }
std::string escaped_string(boost::string_ref const& s) { std::string out; out.reserve(s.size()); char const* p = s.data(); while(p != s.end()) { if(*p == '\r') out.append("\\r"); else if(*p == '\n') out.append("\\n"); else if(*p == '\t') out.append("\\t"); else out.append(p, 1); ++p; } return out; }
fs::path generic_to_path(boost::string_ref x) { return fs::path(x.begin(), x.end()); }
url:: url(const boost::string_ref &ref) : m_string { ref.begin(), ref.end() } { parse(); }
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) {}
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) {}
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())); }
auto operator()(boost::string_ref string) const { return boost::hash_range(string.begin(), string.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(); }