summaryrefslogtreecommitdiff
path: root/internal/xmpmeta/xml/deserializer.h
blob: e7179501e86ade88636c559d786ff994abee7910 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_DESERIALIZER_H_  // NOLINT
#define DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_DESERIALIZER_H_  // NOLINT

#include <memory>
#include <string>
#include <vector>

#include "base/integral_types.h"
#include "base/port.h"

namespace photos_editing_formats {
namespace xml {

// Performs deserialization.
// Example:
//   Deserializer deserializer();
//   string revision;
//   deserializer.ParseString("Revision", &revision);
class Deserializer {
 public:
  virtual ~Deserializer() {}

  // Returns a Deserializer.
  // child_name is the name of the next node to deserialize.
  virtual std::unique_ptr<Deserializer> CreateDeserializer(
      const string& prefix, const string& child_name) const = 0;

  // Returns a Deserializer from a list element node.
  virtual std::unique_ptr<Deserializer> CreateDeserializerFromListElementAt(
      const string& prefix, const string& list_name, int index) const = 0;

  // Parsers for properties with the given prefix.
  // Parses a node such as <NodeName Prefix:Name="Value" />
  virtual bool ParseBase64(const string& prefix, const string& name,
                           string* value) const = 0;
  virtual bool ParseIntArrayBase64(const string& prefix, const string& name,
                                   std::vector<int>* values) const = 0;
  virtual bool ParseFloatArrayBase64(const string& prefix, const string& name,
                                     std::vector<float>* values) const = 0;
  virtual bool ParseDoubleArrayBase64(const string& prefix, const string& name,
                                      std::vector<double>* values) const = 0;
  virtual bool ParseBoolean(const string& prefix, const string& name,
                            bool* value) const = 0;
  virtual bool ParseInt(const string& prefix, const string& name,
                        int* value) const = 0;
  virtual bool ParseFloat(const string& prefix, const string& name,
                          float* value) const = 0;
  virtual bool ParseDouble(const string& prefix, const string& name,
                           double* value) const = 0;
  virtual bool ParseLong(const string& prefix, const string& name,
                         int64* value) const = 0;
  virtual bool ParseString(const string& prefix, const string& name,
                           string* value) const = 0;

  // Parsers for arrays.
  virtual bool ParseIntArray(const string& prefix, const string& list_name,
                             std::vector<int>* values) const = 0;
  virtual bool ParseDoubleArray(const string& prefix, const string& list_name,
                                std::vector<double>* values) const = 0;
};

}  // namespace xml
}  // namespace photos_editing_formats

#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_DESERIALIZER_H_  // NOLINT