paludis  Version 2.6.0
serialise.hh
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
5  *
6  * This file is part of the Paludis package manager. Paludis is free software;
7  * you can redistribute it and/or modify it under the terms of the GNU General
8  * Public License version 2, as published by the Free Software Foundation.
9  *
10  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef PALUDIS_GUARD_PALUDIS_SERIALISE_HH
21 #define PALUDIS_GUARD_PALUDIS_SERIALISE_HH 1
22 
24 #include <paludis/util/pimp.hh>
25 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
26 #include <paludis/serialise-fwd.hh>
28 #include <memory>
29 #include <string>
30 #include <ostream>
31 
32 namespace paludis
33 {
34  namespace serialise
35  {
36  struct container;
37  struct might_be_null;
38  }
39 
40  template <
41  typename Flag1_ = void,
42  typename Flag2_ = void,
43  typename Flag3_ = void
44  >
46  {
47  typedef Flag1_ Flag1;
48  typedef Flag2_ Flag2;
49  typedef Flag3_ Flag3;
50  };
51 
53  {
54  private:
55  Serialiser & _serialiser;
56 
57  public:
60 
61  template <
62  typename Flags_,
63  typename T_>
64  SerialiserObjectWriter & member(
65  const Flags_ &,
66  const std::string & item_name,
67  const T_ &);
68  };
69 
71  {
72  private:
73  std::ostream & _stream;
74 
75  public:
76  Serialiser(std::ostream &);
77  ~Serialiser();
78 
79  SerialiserObjectWriter object(const std::string & class_name)
80  PALUDIS_ATTRIBUTE((warn_unused_result));
81 
82  std::ostream & raw_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
83 
84  void escape_write(const std::string &);
85  };
86 
88  {
89  private:
90  Pimp<Deserialiser> _imp;
91 
92  public:
93  Deserialiser(const Environment * const, std::istream &);
94  ~Deserialiser();
95 
96  const Environment * environment() const PALUDIS_ATTRIBUTE((warn_unused_result));
97 
98  std::istream & stream() PALUDIS_ATTRIBUTE((warn_unused_result));
99  };
100 
102  {
103  private:
105 
106  public:
108  const std::string & class_name,
109  Deserialiser &);
110  ~Deserialisation();
111 
112  const Deserialiser & deserialiser() const PALUDIS_ATTRIBUTE((warn_unused_result));
113 
114  const std::string item_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
115 
116  const std::string class_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
117 
118  const std::string string_value() const PALUDIS_ATTRIBUTE((warn_unused_result));
119 
120  bool null() const PALUDIS_ATTRIBUTE((warn_unused_result));
121 
122  struct ConstIteratorTag;
123  typedef WrappedForwardIterator<ConstIteratorTag,
124  const std::shared_ptr<Deserialisation> > ConstIterator;
125  ConstIterator begin_children() const PALUDIS_ATTRIBUTE((warn_unused_result));
126  ConstIterator end_children() const PALUDIS_ATTRIBUTE((warn_unused_result));
127  };
128 
130  {
131  private:
133 
134  public:
136  Deserialisation &,
137  const std::string & class_name);
138 
139  ~Deserialisator();
140 
141  const Deserialisation & deserialisation() const PALUDIS_ATTRIBUTE((warn_unused_result));
142 
143  template <typename T_> T_ member(const std::string & key_name);
144 
145  const std::shared_ptr<Deserialisation> find_remove_member(
146  const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
147 
148  };
149 
150  template <typename T_>
151  std::shared_ptr<T_> deserialise(
152  const Environment * const,
153  const std::string &,
154  const std::string &) PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
155 
156  extern template class Pimp<Deserialiser>;
157  extern template class Pimp<Deserialisation>;
158  extern template class Pimp<Deserialisator>;
159 }
160 
161 #endif
Definition: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: serialise.hh:70
Definition: serialise.hh:129
Definition: serialise.hh:87
Definition: serialise.hh:45
Definition: environment.hh:200
Definition: serialise.hh:101
Definition: wrapped_forward_iterator-fwd.hh:26
Definition: serialise.hh:52
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59