Boost logo

Boost Users :

Subject: Re: [Boost-users] property tree case sensitivity
From: Daniel Bradburn (moagstar_at_[hidden])
Date: 2012-02-08 05:19:38


See here for details on how to make a case insensitive string type:
http://www.gotw.ca/gotw/029.htm

You can then specialise the property tree with this new type:

typedef basic_ptree< ci_string, std::string > ptree;

You can also use boost::iequals for comparing strings ignoring case,
which may or may not be a better solution depending on your
requirements.Regards

Dan

2012/2/7 Brad Tilley <kj4eit_at_[hidden]>

> I'm trying to make all of the strings (xml tags and attributes)
> contained within a property tree be case insensitive, to make
> comparison easy and consistent.
>
> Here's an example:
>
> boost::property_tree::iptree pt;
> read_xml( file, pt,
> boost::property_tree::xml_parser::trim_whitespace );
>
> // case insensitive
> std::string name = v.second.get<std::string>("<xmlattr>.nAmE");
>
> // case insensitive
> BOOST_FOREACH( boost::property_tree::iptree::value_type const& v,
> pt.get_child("neTwOrK") )
> {
> // fails comparison because "thing" is case sensitive.
> if ( v.first == "tHiNg" )
> {
> ....
> }
> }
>
> Is it possible to make v.first case insensitive as well?
>
> Thanks,
>
> Brad
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net