Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template string_path

boost::property_tree::string_path — Default path class. A path is a sequence of values. Groups of values are separated by the separator value, which defaults to '.' cast to the sequence's value type. The group of values is then passed to the translator to get a key.

Synopsis

// In header: <boost/property_tree/string_path.hpp>

template<typename String, typename Translator> 
class string_path {
public:
  // types
  typedef Translator::external_type key_type; 
  typedef String::value_type        char_type;

  // construct/copy/destruct
  explicit string_path(char_type = char_type('.'));
  string_path(const String &, char_type = char_type('.'), 
              Translator = Translator());
  string_path(const char_type *, char_type = char_type('.'), 
              Translator = Translator());
  string_path(const string_path &);
  string_path & operator=(const string_path &);

  // private member functions
   BOOST_STATIC_ASSERT((is_same< String, typename Translator::internal_type >::value));
  s_c_iter cstart() const;

  // public member functions
  key_type reduce();
  bool empty() const;
  bool single() const;
  char_type separator() const;
  std::string dump() const;
  string_path & operator/=(const string_path &);
};

Description

If instantiated with std::string and id_translator<std::string>, it accepts paths of the form "one.two.three.four".

Template Parameters

  1. typename String

    Any Sequence. If the sequence does not support random- access iteration, concatenation of paths assumes that insertions at the end preserve iterator validity.

  2. typename Translator

    A translator with internal_type == String.

string_path public construct/copy/destruct

  1. explicit string_path(char_type separator = char_type('.'));
    Create an empty path.
  2. string_path(const String & value, char_type separator = char_type('.'), 
                Translator tr = Translator());
    Create a path by parsing the given string.

    Parameters:

    separator

    The separator used in parsing. Defaults to '.'.

    tr

    The translator used by this path to convert the individual parts to keys.

    value

    A sequence, possibly with separators, that describes the path, e.g. "one.two.three".

  3. string_path(const char_type * value, char_type separator = char_type('.'), 
                Translator tr = Translator());
    Create a path by parsing the given string.

    Parameters:

    separator

    The separator used in parsing. Defaults to '.'.

    tr

    The translator used by this path to convert the individual parts to keys.

    value

    A zero-terminated array of values. Only use if zero- termination makes sense for your type, and your sequence supports construction from it. Intended for string literals.

  4. string_path(const string_path & o);
  5. string_path & operator=(const string_path & o);

string_path private member functions

  1.  BOOST_STATIC_ASSERT((is_same< String, typename Translator::internal_type >::value));
  2. s_c_iter cstart() const;

string_path public member functions

  1. key_type reduce();
    Take a single element off the path at the front and return it.
  2. bool empty() const;
    Test if the path is empty.
  3. bool single() const;
    Test if the path contains a single element, i.e. no separators.
  4. char_type separator() const;
    Get the separator used by this path.
  5. std::string dump() const;
  6. string_path & operator/=(const string_path & o);
    Append a second path to this one.

    Requires:

    o's separator is the same as this one's, or o has no separators


PrevUpHomeNext