~ubuntu-branches/debian/sid/boost1.49/sid

« back to all changes in this revision

Viewing changes to boost/property_tree/id_translator.hpp

  • Committer: Package Import Robot
  • Author(s): Steve M. Robbins
  • Date: 2012-02-26 00:31:44 UTC
  • Revision ID: package-import@ubuntu.com-20120226003144-eaytp12cbf6ubpms
Tags: upstream-1.49.0
ImportĀ upstreamĀ versionĀ 1.49.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ----------------------------------------------------------------------------
 
2
// Copyright (C) 2009 Sebastian Redl
 
3
//
 
4
// Distributed under the Boost Software License, Version 1.0. 
 
5
// (See accompanying file LICENSE_1_0.txt or copy at 
 
6
// http://www.boost.org/LICENSE_1_0.txt)
 
7
//
 
8
// For more information, see www.boost.org
 
9
// ----------------------------------------------------------------------------
 
10
 
 
11
#ifndef BOOST_PROPERTY_TREE_ID_TRANSLATOR_HPP_INCLUDED
 
12
#define BOOST_PROPERTY_TREE_ID_TRANSLATOR_HPP_INCLUDED
 
13
 
 
14
#include <boost/property_tree/ptree_fwd.hpp>
 
15
 
 
16
#include <boost/optional.hpp>
 
17
#include <string>
 
18
 
 
19
namespace boost { namespace property_tree
 
20
{
 
21
 
 
22
    /// Simple implementation of the Translator concept. It does no translation.
 
23
    template <typename T>
 
24
    struct id_translator
 
25
    {
 
26
        typedef T internal_type;
 
27
        typedef T external_type;
 
28
 
 
29
        boost::optional<T> get_value(const T &v) { return v; }
 
30
        boost::optional<T> put_value(const T &v) { return v; }
 
31
    };
 
32
 
 
33
    // This is the default translator whenever you get two equal types.
 
34
    template <typename T>
 
35
    struct translator_between<T, T>
 
36
    {
 
37
        typedef id_translator<T> type;
 
38
    };
 
39
 
 
40
    // A more specific specialization for std::basic_string. Otherwise,
 
41
    // stream_translator's specialization wins.
 
42
    template <typename Ch, typename Traits, typename Alloc>
 
43
    struct translator_between< std::basic_string<Ch, Traits, Alloc>,
 
44
                               std::basic_string<Ch, Traits, Alloc> >
 
45
    {
 
46
        typedef id_translator< std::basic_string<Ch, Traits, Alloc> > type;
 
47
    };
 
48
 
 
49
}}
 
50
 
 
51
#endif