diff --git a/SConstruct b/SConstruct index ef202df1a..989954c37 100644 --- a/SConstruct +++ b/SConstruct @@ -919,7 +919,7 @@ def boost_regex_has_icu(context): int main() { - UnicodeString ustr; + icu::UnicodeString ustr; try { boost::u32regex pattern = boost::make_u32regex(ustr); } diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index f2271da1a..d1e7fc272 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -32,6 +32,7 @@ // mapnik +#include #include #include #include @@ -121,14 +122,14 @@ boost::python::dict attributes(mapnik::feature_impl const& f) } // end anonymous namespace -struct UnicodeString_from_python_str +struct unicode_string_from_python_str { - UnicodeString_from_python_str() + unicode_string_from_python_str() { boost::python::converter::registry::push_back( &convertible, &construct, - boost::python::type_id()); + boost::python::type_id()); } static void* convertible(PyObject* obj_ptr) @@ -168,9 +169,9 @@ struct UnicodeString_from_python_str } if (value == 0) boost::python::throw_error_already_set(); void* storage = ( - (boost::python::converter::rvalue_from_python_storage*) + (boost::python::converter::rvalue_from_python_storage*) data)->storage.bytes; - new (storage) UnicodeString(value); + new (storage) mapnik::value_unicode_string(value); data->convertible = storage; } }; @@ -219,7 +220,7 @@ void export_feature() implicitly_convertible(); // http://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converters/ - UnicodeString_from_python_str(); + unicode_string_from_python_str(); value_null_from_python(); class_ diff --git a/bindings/python/mapnik_parameters.cpp b/bindings/python/mapnik_parameters.cpp index b56a0fdd1..eb213e2d1 100644 --- a/bindings/python/mapnik_parameters.cpp +++ b/bindings/python/mapnik_parameters.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include // stl #include @@ -82,7 +83,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite extract ex0(obj); extract ex1(obj); extract ex2(obj); - extract ex3(obj); + extract ex3(obj); // TODO - this is never hit - we need proper python string -> std::string to get invoked here if (ex0.check()) @@ -175,7 +176,7 @@ mapnik::value_holder get_param(mapnik::parameter const& p, int index) } } -boost::shared_ptr create_parameter(UnicodeString const& key, mapnik::value_holder const& value) +boost::shared_ptr create_parameter(mapnik::value_unicode_string const& key, mapnik::value_holder const& value) { std::string key_utf8; mapnik::to_utf8(key, key_utf8); @@ -184,7 +185,7 @@ boost::shared_ptr create_parameter(UnicodeString const& key, // needed for Python_Unicode to std::string (utf8) conversion -boost::shared_ptr create_parameter_from_string(UnicodeString const& key, UnicodeString const& ustr) +boost::shared_ptr create_parameter_from_string(mapnik::value_unicode_string const& key, mapnik::value_unicode_string const& ustr) { std::string key_utf8; std::string ustr_utf8; diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index d8c3732e4..b0da07f76 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -49,13 +49,13 @@ struct unicode_impl template struct result { - typedef UnicodeString type; + typedef mapnik::value_unicode_string type; }; explicit unicode_impl(mapnik::transcoder const& tr) : tr_(tr) {} - UnicodeString operator()(std::string const& str) const + mapnik::value_unicode_string operator()(std::string const& str) const { return tr_.transcode(str.c_str()); } diff --git a/include/mapnik/expression_node.hpp b/include/mapnik/expression_node.hpp index e344f62ce..851d70074 100644 --- a/include/mapnik/expression_node.hpp +++ b/include/mapnik/expression_node.hpp @@ -24,6 +24,7 @@ #define MAPNIK_EXPRESSION_NODE_HPP // mapnik +#include #include #include #include @@ -87,7 +88,7 @@ struct binary_node struct regex_match_node { - regex_match_node (expr_node const& a, UnicodeString const& ustr); + regex_match_node (expr_node const& a, mapnik::value_unicode_string const& ustr); expr_node expr; boost::u32regex pattern; }; @@ -95,10 +96,10 @@ struct regex_match_node struct regex_replace_node { - regex_replace_node (expr_node const& a, UnicodeString const& ustr, UnicodeString const& f); + regex_replace_node (expr_node const& a, mapnik::value_unicode_string const& ustr, mapnik::value_unicode_string const& f); expr_node expr; boost::u32regex pattern; - UnicodeString format; + mapnik::value_unicode_string format; }; #else diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp index 5d4736125..8e0e846ee 100644 --- a/include/mapnik/font_engine_freetype.hpp +++ b/include/mapnik/font_engine_freetype.hpp @@ -52,9 +52,6 @@ #include #include -// uci -#include - struct FT_LibraryRec_; namespace mapnik @@ -106,7 +103,7 @@ public: size_type size() const; glyph_ptr get_glyph(unsigned c) const; char_info character_dimensions(unsigned c); - void get_string_info(string_info & info, UnicodeString const& ustr, char_properties *format); + void get_string_info(string_info & info, mapnik::value_unicode_string const& ustr, char_properties *format); void set_pixel_sizes(unsigned size); void set_character_sizes(double size); private: diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index d5d16c47d..7c7666ddb 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include #include #include @@ -120,7 +121,7 @@ struct utf8 template struct result { typedef std::string type; }; - std::string operator() (UnicodeString const& ustr) const + std::string operator() (mapnik::value_unicode_string const& ustr) const { std::string result; to_utf8(ustr,result); @@ -232,7 +233,7 @@ struct feature_generator_grammar: karma::rule pair; karma::rule value; karma::rule value_null_; - karma::rule ustring; + karma::rule ustring; typename karma::int_generator int__; // phoenix functions phoenix::function id_; diff --git a/include/mapnik/label_collision_detector.hpp b/include/mapnik/label_collision_detector.hpp index 2db67d48f..76d4a1f57 100644 --- a/include/mapnik/label_collision_detector.hpp +++ b/include/mapnik/label_collision_detector.hpp @@ -26,10 +26,10 @@ // mapnik #include #include +#include // stl #include -#include namespace mapnik { @@ -142,10 +142,10 @@ public: struct label { label(box2d const& b) : box(b), text() {} - label(box2d const& b, UnicodeString const& t) : box(b), text(t) {} + label(box2d const& b, mapnik::value_unicode_string const& t) : box(b), text(t) {} box2d box; - UnicodeString text; + mapnik::value_unicode_string text; }; private: @@ -174,7 +174,7 @@ public: return true; } - bool has_placement(box2d const& box, UnicodeString const& text, double distance) + bool has_placement(box2d const& box, mapnik::value_unicode_string const& text, double distance) { box2d bigger_box(box.minx() - distance, box.miny() - distance, box.maxx() + distance, box.maxy() + distance); tree_t::query_iterator itr = tree_.query_in_box(bigger_box); @@ -213,7 +213,7 @@ public: tree_.insert(label(box), box); } - void insert(box2d const& box, UnicodeString const& text) + void insert(box2d const& box, mapnik::value_unicode_string const& text) { tree_.insert(label(box, text), box); } diff --git a/include/mapnik/processed_text.hpp b/include/mapnik/processed_text.hpp index 5219a6785..d13692ee8 100644 --- a/include/mapnik/processed_text.hpp +++ b/include/mapnik/processed_text.hpp @@ -26,6 +26,7 @@ #include #include #include +#include // stl #include @@ -42,14 +43,15 @@ class MAPNIK_DECL processed_text : mapnik::noncopyable public: struct processed_expression { - processed_expression(char_properties const& properties, UnicodeString const& text) - : p(properties), str(text) {} + processed_expression(char_properties const& properties, mapnik::value_unicode_string const& text) + : p(properties), + str(text) {} char_properties p; - UnicodeString str; + mapnik::value_unicode_string str; }; public: processed_text(face_manager & font_manager, double scale_factor); - void push_back(char_properties const& properties, UnicodeString const& text); + void push_back(char_properties const& properties, mapnik::value_unicode_string const& text); unsigned size() const { return expr_list_.size(); } unsigned empty() const { return expr_list_.empty(); } void clear(); diff --git a/include/mapnik/text_path.hpp b/include/mapnik/text_path.hpp index dc2f50545..7eae3f036 100644 --- a/include/mapnik/text_path.hpp +++ b/include/mapnik/text_path.hpp @@ -27,6 +27,7 @@ #include #include #include +#include //stl #include @@ -34,9 +35,6 @@ // boost #include -// uci -#include - namespace mapnik { @@ -45,10 +43,10 @@ class string_info : private mapnik::noncopyable protected: typedef std::vector characters_t; characters_t characters_; - UnicodeString text_; + mapnik::value_unicode_string text_; bool is_rtl; public: - string_info(UnicodeString const& text) + string_info(mapnik::value_unicode_string const& text) : characters_(), text_(text), is_rtl(false) @@ -69,7 +67,7 @@ public: characters_.push_back(info); } - void add_text(UnicodeString const& text) + void add_text(mapnik::value_unicode_string const& text) { text_ += text; } @@ -99,13 +97,14 @@ public: return at(i); } - UnicodeString const& get_string() const + mapnik::value_unicode_string const& get_string() const { return text_; } bool has_line_breaks() const { + // uint16_t UChar break_char = '\n'; return (text_.indexOf(break_char) >= 0); } diff --git a/include/mapnik/unicode.hpp b/include/mapnik/unicode.hpp index fd4e8e40a..dd1441be3 100644 --- a/include/mapnik/unicode.hpp +++ b/include/mapnik/unicode.hpp @@ -28,7 +28,7 @@ #include // icu -#include +#include #include // boost @@ -43,7 +43,7 @@ class MAPNIK_DECL transcoder : private mapnik::noncopyable { public: explicit transcoder (std::string const& encoding); - UnicodeString transcode(const char* data, boost::int32_t length = -1) const; + mapnik::value_unicode_string transcode(const char* data, boost::int32_t length = -1) const; ~transcoder(); private: bool ok_; @@ -52,7 +52,7 @@ private: } namespace U_ICU_NAMESPACE { -inline std::size_t hash_value(const UnicodeString& val) { +inline std::size_t hash_value(mapnik::value_unicode_string const& val) { return val.hashCode(); } } diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 9ca954a6f..33de4dd1e 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -42,14 +42,15 @@ // stl #include #include -// uci + +// icu #include #include namespace mapnik { -inline void to_utf8(UnicodeString const& input, std::string & target) +inline void to_utf8(mapnik::value_unicode_string const& input, std::string & target) { if (input.isEmpty()) return; diff --git a/include/mapnik/value_types.hpp b/include/mapnik/value_types.hpp index c188d40b9..a35491d03 100644 --- a/include/mapnik/value_types.hpp +++ b/include/mapnik/value_types.hpp @@ -42,7 +42,7 @@ typedef int value_integer; #endif typedef double value_double; -typedef UnicodeString value_unicode_string; +typedef icu::UnicodeString value_unicode_string; typedef bool value_bool; struct value_null diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index dd5e16723..10e320ef9 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -81,7 +82,7 @@ struct attr_value_converter : public boost::static_visitor #include #include +#include #include // ogr @@ -192,7 +193,7 @@ feature_ptr occi_featureset::next() case oracle::occi::OCCI_SQLT_TIMESTAMP: case oracle::occi::OCCI_SQLT_TIMESTAMP_LTZ: case oracle::occi::OCCI_SQLT_TIMESTAMP_TZ: - feature->put(fld_name, (UnicodeString)tr_->transcode(rs_->getString(i + 1).c_str())); + feature->put(fld_name, static_cast(tr_->transcode(rs_->getString(i + 1).c_str()))); break; case oracle::occi::OCCIINTERVALDS: case oracle::occi::OCCIINTERVALYM: diff --git a/plugins/input/ogr/ogr_featureset.cpp b/plugins/input/ogr/ogr_featureset.cpp index afa5bc40e..7d3cc638b 100644 --- a/plugins/input/ogr/ogr_featureset.cpp +++ b/plugins/input/ogr/ogr_featureset.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include // ogr @@ -129,8 +130,7 @@ feature_ptr ogr_featureset::next() case OFTString: case OFTWideString: // deprecated ! { - UnicodeString ustr = tr_->transcode(poFeature->GetFieldAsString(i)); - feature->put( fld_name, ustr); + feature->put( fld_name, tr_->transcode(poFeature->GetFieldAsString(i))); break; } diff --git a/plugins/input/ogr/ogr_index_featureset.cpp b/plugins/input/ogr/ogr_index_featureset.cpp index 32bd20001..90d09d0c0 100644 --- a/plugins/input/ogr/ogr_index_featureset.cpp +++ b/plugins/input/ogr/ogr_index_featureset.cpp @@ -154,8 +154,7 @@ feature_ptr ogr_index_featureset::next() case OFTString: case OFTWideString: // deprecated ! { - UnicodeString ustr = tr_->transcode(poFeature->GetFieldAsString (i)); - feature->put(fld_name,ustr); + feature->put(fld_name,tr_->transcode(poFeature->GetFieldAsString (i))); break; } diff --git a/plugins/input/sqlite/sqlite_featureset.cpp b/plugins/input/sqlite/sqlite_featureset.cpp index 2f1735e47..56b59effb 100644 --- a/plugins/input/sqlite/sqlite_featureset.cpp +++ b/plugins/input/sqlite/sqlite_featureset.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include // ogr @@ -123,8 +124,7 @@ feature_ptr sqlite_featureset::next() { int text_col_size; const char * text_data = rs_->column_text(i, text_col_size); - UnicodeString ustr = tr_->transcode(text_data, text_col_size); - feature->put(fld_name_str, ustr); + feature->put(fld_name_str, tr_->transcode(text_data, text_col_size)); break; } diff --git a/plugins/input/templates/helloworld/hello_featureset.cpp b/plugins/input/templates/helloworld/hello_featureset.cpp index c98b0e461..deaabdff3 100644 --- a/plugins/input/templates/helloworld/hello_featureset.cpp +++ b/plugins/input/templates/helloworld/hello_featureset.cpp @@ -1,6 +1,7 @@ // mapnik #include #include +#include // boost #include @@ -32,7 +33,7 @@ mapnik::feature_ptr hello_featureset::next() ++feature_id_; // create an attribute pair of key:value - UnicodeString ustr = tr_->transcode("hello world!"); + mapnik::value_unicode_string ustr = tr_->transcode("hello world!"); feature->put(attribute,ustr); // we need a geometry to display so just for fun here diff --git a/src/expression_node.cpp b/src/expression_node.cpp index 4d83b1452..aeae3d745 100644 --- a/src/expression_node.cpp +++ b/src/expression_node.cpp @@ -21,17 +21,18 @@ *****************************************************************************/ #include +#include namespace mapnik { #if defined(BOOST_REGEX_HAS_ICU) -regex_match_node::regex_match_node (expr_node const& a, UnicodeString const& ustr) +regex_match_node::regex_match_node (expr_node const& a, mapnik::value_unicode_string const& ustr) : expr(a), pattern(boost::make_u32regex(ustr)) {} -regex_replace_node::regex_replace_node (expr_node const& a, UnicodeString const& ustr, UnicodeString const& f) +regex_replace_node::regex_replace_node (expr_node const& a, mapnik::value_unicode_string const& ustr, mapnik::value_unicode_string const& f) : expr(a), pattern(boost::make_u32regex(ustr)), format(f) {} diff --git a/src/expression_string.cpp b/src/expression_string.cpp index 484d3c273..5cd4803a2 100644 --- a/src/expression_string.cpp +++ b/src/expression_string.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include // boost @@ -35,10 +36,6 @@ #include // for u32regex #endif -// icu -#include // for UnicodeString - - namespace mapnik { @@ -96,7 +93,7 @@ struct expression_string : boost::static_visitor str_ +=".match('"; #if defined(BOOST_REGEX_HAS_ICU) std::string utf8; - UnicodeString ustr = UnicodeString::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); + mapnik::value_unicode_string ustr = mapnik::value_unicode_string::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); to_utf8(ustr,utf8); str_ += utf8; #else @@ -112,7 +109,7 @@ struct expression_string : boost::static_visitor str_ += "'"; #if defined(BOOST_REGEX_HAS_ICU) std::string utf8; - UnicodeString ustr = UnicodeString::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); + mapnik::value_unicode_string ustr = mapnik::value_unicode_string::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); to_utf8(ustr,utf8); str_ += utf8; str_ +="','"; diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index f9b2f84e0..3473f4cdd 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #if defined(GRID_RENDERER) #include @@ -350,12 +351,12 @@ char_info font_face_set::character_dimensions(unsigned int c) } -void font_face_set::get_string_info(string_info & info, UnicodeString const& ustr, char_properties *format) +void font_face_set::get_string_info(string_info & info, mapnik::value_unicode_string const& ustr, char_properties *format) { double avg_height = character_dimensions('X').height(); UErrorCode err = U_ZERO_ERROR; - UnicodeString reordered; - UnicodeString shaped; + mapnik::value_unicode_string reordered; + mapnik::value_unicode_string shaped; int32_t length = ustr.length(); diff --git a/src/formatting/text.cpp b/src/formatting/text.cpp index 1137b0492..3a4f80cea 100644 --- a/src/formatting/text.cpp +++ b/src/formatting/text.cpp @@ -27,6 +27,7 @@ #include #include #include +#include // boost #include @@ -53,7 +54,7 @@ node_ptr text_node::from_xml(xml_node const& xml) void text_node::apply(char_properties const& p, feature_impl const& feature, processed_text &output) const { - UnicodeString text_str = boost::apply_visitor(evaluate(feature), *text_).to_unicode(); + mapnik::value_unicode_string text_str = boost::apply_visitor(evaluate(feature), *text_).to_unicode(); if (p.text_transform == UPPERCASE) { text_str = text_str.toUpper(); diff --git a/src/processed_text.cpp b/src/processed_text.cpp index 4d2064d7e..52be27c9a 100644 --- a/src/processed_text.cpp +++ b/src/processed_text.cpp @@ -23,11 +23,12 @@ #include #include #include +#include namespace mapnik { -void processed_text::push_back(char_properties const& properties, UnicodeString const& text) +void processed_text::push_back(char_properties const& properties, mapnik::value_unicode_string const& text) { expr_list_.push_back(processed_expression(properties, text)); } diff --git a/src/unicode.cpp b/src/unicode.cpp index 726ec8293..69e3cd4fb 100644 --- a/src/unicode.cpp +++ b/src/unicode.cpp @@ -22,6 +22,7 @@ // mapnik #include +#include // stl #include @@ -39,11 +40,11 @@ transcoder::transcoder (std::string const& encoding) // TODO ?? } -UnicodeString transcoder::transcode(const char* data, boost::int32_t length) const +mapnik::value_unicode_string transcoder::transcode(const char* data, boost::int32_t length) const { UErrorCode err = U_ZERO_ERROR; - UnicodeString ustr(data,length,conv_,err); + mapnik::value_unicode_string ustr(data,length,conv_,err); if (ustr.isBogus()) { ustr.remove(); diff --git a/tests/cpp_tests/fontset_runtime_test.cpp b/tests/cpp_tests/fontset_runtime_test.cpp index f6e351f93..4e287296a 100644 --- a/tests/cpp_tests/fontset_runtime_test.cpp +++ b/tests/cpp_tests/fontset_runtime_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -40,7 +41,7 @@ int main(int argc, char** argv) ctx->push("name"); mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1)); mapnik::transcoder tr("utf-8"); - UnicodeString ustr = tr.transcode("hello world!"); + mapnik::value_unicode_string ustr = tr.transcode("hello world!"); feature->put("name",ustr); mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point); pt->move_to(128,128);