Ticket #8631: property_pree_locale.patch
File property_pree_locale.patch, 9.9 KB (added by , 9 years ago) |
---|
-
detail/ptree_implementation.hpp
655 655 656 656 template<class K, class D, class C> 657 657 template<class Type> inline 658 Type basic_ptree<K, D, C>::get_value( ) const658 Type basic_ptree<K, D, C>::get_value(const std::locale & loc) const 659 659 { 660 660 return get_value<Type>( 661 typename translator_between<data_type, Type>::type( ));661 typename translator_between<data_type, Type>::type(loc)); 662 662 } 663 663 664 664 template<class K, class D, class C> … … 683 683 template<class K, class D, class C> 684 684 template<class Type> inline 685 685 typename boost::disable_if<detail::is_translator<Type>, Type>::type 686 basic_ptree<K, D, C>::get_value(const Type &default_value ) const686 basic_ptree<K, D, C>::get_value(const Type &default_value, const std::locale & loc) const 687 687 { 688 688 return get_value(default_value, 689 typename translator_between<data_type, Type>::type( ));689 typename translator_between<data_type, Type>::type(loc)); 690 690 } 691 691 692 692 template<class K, class D, class C> … … 710 710 711 711 template<class K, class D, class C> 712 712 template<class Type> inline 713 optional<Type> basic_ptree<K, D, C>::get_value_optional( ) const713 optional<Type> basic_ptree<K, D, C>::get_value_optional(const std::locale & loc) const 714 714 { 715 715 return get_value_optional<Type>( 716 typename translator_between<data_type, Type>::type( ));716 typename translator_between<data_type, Type>::type(loc)); 717 717 } 718 718 719 719 template<class K, class D, class C> … … 727 727 728 728 template<class K, class D, class C> 729 729 template<class Type> inline 730 Type basic_ptree<K, D, C>::get(const path_type &path ) const730 Type basic_ptree<K, D, C>::get(const path_type &path, const std::locale & loc) const 731 731 { 732 return get_child(path).BOOST_NESTED_TEMPLATE get_value<Type>( );732 return get_child(path).BOOST_NESTED_TEMPLATE get_value<Type>(loc); 733 733 } 734 734 735 735 template<class K, class D, class C> … … 757 757 template<class Type> inline 758 758 typename boost::disable_if<detail::is_translator<Type>, Type>::type 759 759 basic_ptree<K, D, C>::get(const path_type &path, 760 const Type &default_value ) const760 const Type &default_value, const std::locale & loc) const 761 761 { 762 return get_optional<Type>(path ).get_value_or(default_value);762 return get_optional<Type>(path, loc).get_value_or(default_value); 763 763 } 764 764 765 765 template<class K, class D, class C> … … 789 789 template<class K, class D, class C> 790 790 template<class Type> 791 791 optional<Type> basic_ptree<K, D, C>::get_optional( 792 const path_type &path ) const792 const path_type &path, const std::locale & loc) const 793 793 { 794 794 if (optional<const self_type&> child = get_child_optional(path)) 795 return child.get().BOOST_NESTED_TEMPLATE get_value_optional<Type>( );795 return child.get().BOOST_NESTED_TEMPLATE get_value_optional<Type>(loc); 796 796 else 797 797 return optional<Type>(); 798 798 } … … 812 812 813 813 template<class K, class D, class C> 814 814 template<class Type> inline 815 void basic_ptree<K, D, C>::put_value(const Type &value )815 void basic_ptree<K, D, C>::put_value(const Type &value, const std::locale & loc) 816 816 { 817 put_value(value, typename translator_between<data_type, Type>::type( ));817 put_value(value, typename translator_between<data_type, Type>::type(loc)); 818 818 } 819 819 820 820 template<class K, class D, class C> … … 835 835 template<class K, class D, class C> 836 836 template<class Type> inline 837 837 basic_ptree<K, D, C> & basic_ptree<K, D, C>::put( 838 const path_type &path, const Type &value )838 const path_type &path, const Type &value, const std::locale & loc) 839 839 { 840 840 return put(path, value, 841 typename translator_between<data_type, Type>::type( ));841 typename translator_between<data_type, Type>::type(loc)); 842 842 } 843 843 844 844 template<class K, class D, class C> … … 854 854 template<class K, class D, class C> 855 855 template<class Type> inline 856 856 basic_ptree<K, D, C> & basic_ptree<K, D, C>::add( 857 const path_type &path, const Type &value )857 const path_type &path, const Type &value, const std::locale & loc) 858 858 { 859 859 return add(path, value, 860 typename translator_between<data_type, Type>::type( ));860 typename translator_between<data_type, Type>::type(loc)); 861 861 } 862 862 863 863 -
id_translator.hpp
28 28 29 29 boost::optional<T> get_value(const T &v) { return v; } 30 30 boost::optional<T> put_value(const T &v) { return v; } 31 32 explicit id_translator() 33 { 34 } 35 explicit id_translator(const std::locale &) 36 { 37 } 31 38 }; 32 39 33 40 // This is the default translator whenever you get two equal types. -
ptree.hpp
310 310 * @throw ptree_bad_data if the conversion fails. 311 311 */ 312 312 template<class Type> 313 Type get_value( ) const;313 Type get_value(const std::locale & loc = std::locale()) const; 314 314 315 315 /** Take the value of this node and attempt to translate it to a 316 316 * @c Type object using the supplied translator. Return @p default_value … … 333 333 */ 334 334 template<class Type> 335 335 typename boost::disable_if<detail::is_translator<Type>, Type>::type 336 get_value(const Type &default_value ) const;336 get_value(const Type &default_value, const std::locale & loc = std::locale()) const; 337 337 338 338 /** Make get_value do the right thing for string literals. */ 339 339 template <class Ch> … … 355 355 * this fails. 356 356 */ 357 357 template<class Type> 358 optional<Type> get_value_optional( ) const;358 optional<Type> get_value_optional(const std::locale & loc = std::locale()) const; 359 359 360 360 /** Replace the value at this node with the given value, translated 361 361 * to the tree's data type using the supplied translator. … … 369 369 * @throw ptree_bad_data if the conversion fails. 370 370 */ 371 371 template<class Type> 372 void put_value(const Type &value );372 void put_value(const Type &value, const std::locale & loc = std::locale()); 373 373 374 374 /** Shorthand for get_child(path).get_value(tr). */ 375 375 template<class Type, class Translator> … … 378 378 379 379 /** Shorthand for get_child(path).get_value\<Type\>(). */ 380 380 template<class Type> 381 Type get(const path_type &path ) const;381 Type get(const path_type &path, const std::locale & loc = std::locale()) const; 382 382 383 383 /** Shorthand for get_child(path, empty_ptree()) 384 384 * .get_value(default_value, tr). … … 405 405 */ 406 406 template<class Type> 407 407 typename boost::disable_if<detail::is_translator<Type>, Type>::type 408 get(const path_type &path, const Type &default_value ) const;408 get(const path_type &path, const Type &default_value, const std::locale & loc = std::locale()) const; 409 409 410 410 /** Make get do the right thing for string literals. */ 411 411 template <class Ch> … … 435 435 * That is, return the value if it exists and can be converted, or nil. 436 436 */ 437 437 template<class Type> 438 optional<Type> get_optional(const path_type &path ) const;438 optional<Type> get_optional(const path_type &path, const std::locale & loc = std::locale()) const; 439 439 440 440 /** Set the value of the node at the given path to the supplied value, 441 441 * translated to the tree's data type. If the node doesn't exist, it is … … 453 453 * @throw ptree_bad_data if the conversion fails. 454 454 */ 455 455 template<class Type> 456 self_type &put(const path_type &path, const Type &value );456 self_type &put(const path_type &path, const Type &value, const std::locale & loc = std::locale()); 457 457 458 458 /** If the node identified by the path does not exist, create it, 459 459 * including all its missing parents. … … 484 484 * @throw ptree_bad_data if the conversion fails. 485 485 */ 486 486 template<class Type> 487 self_type &add(const path_type &path, const Type &value );487 self_type &add(const path_type &path, const Type &value, const std::locale & loc = std::locale()); 488 488 489 489 private: 490 490 // Hold the data of this node -
stream_translator.hpp
140 140 i < (std::numeric_limits<signed char>::min)()) 141 141 { 142 142 s.clear(); // guarantees eof to be unset 143 s.setstate(std::ios_base::badbit); 143 144 return; 144 145 } 145 146 e = (signed char)i; … … 161 162 // out of range? 162 163 if(i > (std::numeric_limits<unsigned char>::max)()) { 163 164 s.clear(); // guarantees eof to be unset 165 s.setstate(std::ios_base::badbit); 164 166 return; 165 167 } 166 168 e = (unsigned char)i; … … 179 181 typedef std::basic_string<Ch, Traits, Alloc> internal_type; 180 182 typedef E external_type; 181 183 182 explicit stream_translator(std::locale loc = std::locale())184 explicit stream_translator(std::locale loc) 183 185 : m_loc(loc) 184 186 {} 185 187