1 #ifndef DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_DESERIALIZER_H_ // NOLINT 2 #define DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_DESERIALIZER_H_ // NOLINT 3 4 #include <memory> 5 #include <string> 6 #include <vector> 7 8 #include "base/integral_types.h" 9 #include "base/port.h" 10 11 namespace dynamic_depth { 12 namespace xmpmeta { 13 namespace xml { 14 15 // Performs deserialization. 16 // Example: 17 // Deserializer deserializer(); 18 // string revision; 19 // deserializer.ParseString("Revision", &revision); 20 class Deserializer { 21 public: ~Deserializer()22 virtual ~Deserializer() {} 23 24 // Returns a Deserializer. 25 // child_name is the name of the next node to deserialize. 26 virtual std::unique_ptr<Deserializer> CreateDeserializer( 27 const string& prefix, const string& child_name) const = 0; 28 29 // Returns a Deserializer from a list element node. 30 virtual std::unique_ptr<Deserializer> CreateDeserializerFromListElementAt( 31 const string& prefix, const string& list_name, int index) const = 0; 32 33 // Parsers for properties with the given prefix. 34 // Parses a node such as <NodeName Prefix:Name="Value" /> 35 virtual bool ParseBase64(const string& prefix, const string& name, 36 string* value) const = 0; 37 virtual bool ParseIntArrayBase64(const string& prefix, const string& name, 38 std::vector<int>* values) const = 0; 39 virtual bool ParseFloatArrayBase64(const string& prefix, const string& name, 40 std::vector<float>* values) const = 0; 41 virtual bool ParseDoubleArrayBase64(const string& prefix, const string& name, 42 std::vector<double>* values) const = 0; 43 virtual bool ParseBoolean(const string& prefix, const string& name, 44 bool* value) const = 0; 45 virtual bool ParseInt(const string& prefix, const string& name, 46 int* value) const = 0; 47 virtual bool ParseFloat(const string& prefix, const string& name, 48 float* value) const = 0; 49 virtual bool ParseDouble(const string& prefix, const string& name, 50 double* value) const = 0; 51 virtual bool ParseLong(const string& prefix, const string& name, 52 int64* value) const = 0; 53 virtual bool ParseString(const string& prefix, const string& name, 54 string* value) const = 0; 55 56 // Parsers for arrays. 57 virtual bool ParseIntArray(const string& prefix, const string& list_name, 58 std::vector<int>* values) const = 0; 59 virtual bool ParseDoubleArray(const string& prefix, const string& list_name, 60 std::vector<double>* values) const = 0; 61 }; 62 63 } // namespace xml 64 } // namespace xmpmeta 65 } // namespace dynamic_depth 66 67 #endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_DESERIALIZER_H_ // NOLINT 68