1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef VCARD_UTIL_H
17 #define VCARD_UTIL_H
18 
19 #include <iostream>
20 #include <map>
21 #include <stdint.h>
22 #include <string>
23 #include <vector>
24 
25 namespace stub {
26 enum class VCardVersion : uint8_t { VER_OTHER = 0x00, VER_2_1 = 0x21, VER_3_0 = 0x30 };
27 
28 typedef std::multimap<std::string, std::string> VCardParams;
29 
30 class VCardProperty {
31 public:
VCardProperty(VCardVersion ver,std::string group,std::string name,std::string value,std::string paramsStr)32     VCardProperty(VCardVersion ver, std::string group, std::string name, std::string value, std::string paramsStr)
33     {}
VCardProperty(std::string group,std::string name,std::string value,VCardParams params)34     VCardProperty(std::string group, std::string name, std::string value, VCardParams params)
35     {}
36     virtual ~VCardProperty() = default;
GetGroup()37     std::string GetGroup() const
38     {
39         return "";
40     }
GetName()41     std::string GetName() const
42     {
43         return "";
44     }
GetValues()45     const std::vector<std::string> &GetValues() const
46     {
47         static std::vector<std::string> v;
48         return v;
49     }
GetParams()50     const VCardParams &GetParams() const
51     {
52         static VCardParams v;
53         return v;
54     }
BuildParamString(VCardVersion ver,std::vector<uint8_t> & outList)55     void BuildParamString(VCardVersion ver, std::vector<uint8_t> &outList) const
56     {}
BuildValueString(std::vector<uint8_t> & outList)57     void BuildValueString(std::vector<uint8_t> &outList) const
58     {}
59 
60 private:
61     std::string group_ = "";
62     std::string name_ = "";
63     std::vector<std::string> values_ {};
64     VCardParams params_ {};
65 };
66 
67 class VCard {
68 public:
69     VCard() = default;
70     virtual ~VCard() = default;
GetVersion()71     VCardVersion GetVersion() const
72     {
73         static VCardVersion v;
74         return v;
75     }
SetVersion(const VCardVersion ver)76     void SetVersion(const VCardVersion ver)
77     {}
Version2Str(VCardVersion ver)78     static std::string Version2Str(VCardVersion ver)
79     {
80         return "";
81     }
Str2Version(const std::string & str)82     static VCardVersion Str2Version(const std::string &str)
83     {
84         static VCardVersion v;
85         return v;
86     }
Properties()87     const std::vector<VCardProperty> &Properties() const
88     {
89         static std::vector<VCardProperty> v;
90         return v;
91     }
AddProperty(const VCardProperty & property)92     void AddProperty(const VCardProperty &property)
93     {}
HasProperty(std::string propertyId)94     bool HasProperty(std::string propertyId)
95     {
96         return true;
97     }
98 };
99 
100 class VCardUtil {
101 public:
Build(const VCard & vCard,VCardVersion ver)102     static std::vector<uint8_t> Build(const VCard &vCard, VCardVersion ver)
103     {
104         static std::vector<uint8_t> v;
105         return v;
106     }
Build(const std::vector<VCard> & vCards,VCardVersion ver)107     static std::vector<uint8_t> Build(const std::vector<VCard> &vCards, VCardVersion ver)
108     {
109         static std::vector<uint8_t> v;
110         return v;
111     }
Parse(std::istream & is)112     static std::vector<VCard> Parse(std::istream &is)
113     {
114         std::vector<VCard> v;
115         return v;
116     }
Parse(const std::vector<uint8_t> & datas)117     static std::vector<VCard> Parse(const std::vector<uint8_t> &datas)
118     {
119         std::vector<VCard> v;
120         return v;
121     }
122 
123 private:
124     VCardUtil() = default;
125     virtual ~VCardUtil() = default;
126 };
127 }  // namespace stub
128 #endif // VCARD_UTIL_H