1 /*
2  * Copyright (C) 2023 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 #include "vcard_raw_data.h"
16 
17 #include "telephony_errors.h"
18 #include "telephony_log_wrapper.h"
19 
20 namespace OHOS {
21 namespace Telephony {
22 
SetByte(const std::string & byte)23 void VCardRawData::SetByte(const std::string &byte)
24 {
25     bytes_ = byte;
26 }
27 
SetName(const std::string & name)28 void VCardRawData::SetName(const std::string &name)
29 {
30     name_ = name;
31 }
32 
SetRawValue(const std::string & rawValue)33 void VCardRawData::SetRawValue(const std::string &rawValue)
34 {
35     rawValue_ = rawValue;
36 }
37 
SetValues(const std::vector<std::string> & values)38 void VCardRawData::SetValues(const std::vector<std::string> &values)
39 {
40     values_ = values;
41 }
42 
AppendValues(const std::vector<std::string> & values)43 void VCardRawData::AppendValues(const std::vector<std::string> &values)
44 {
45     values_.insert(values_.end(), values.begin(), values.end());
46 }
47 
AppendGroup(const std::string & group)48 void VCardRawData::AppendGroup(const std::string &group)
49 {
50     groups_.push_back(group);
51 }
52 
AppendParameter(const std::string & param,const std::string & value)53 void VCardRawData::AppendParameter(const std::string &param, const std::string &value)
54 {
55     auto it = parasMap_.find(param);
56     if (it != parasMap_.end()) {
57         it->second.push_back(value);
58     } else {
59         parasMap_[param] = { value };
60     }
61 }
62 
GetParameters(const std::string & key)63 std::vector<std::string> VCardRawData::GetParameters(const std::string &key)
64 {
65     auto it = parasMap_.find(key);
66     if (it != parasMap_.end()) {
67         return it->second;
68     }
69     std::vector<std::string> emptyVector;
70     return emptyVector;
71 }
72 
GetName()73 std::string VCardRawData::GetName()
74 {
75     return name_;
76 }
77 
GetRawValue()78 std::string VCardRawData::GetRawValue()
79 {
80     return rawValue_;
81 }
82 
GetByte()83 std::string VCardRawData::GetByte()
84 {
85     return bytes_;
86 }
87 
GetValue()88 std::vector<std::string> VCardRawData::GetValue()
89 {
90     return values_;
91 }
92 
GetGroup()93 std::vector<std::string> VCardRawData::GetGroup()
94 {
95     return groups_;
96 }
97 
GetParasMap()98 std::map<std::string, std::vector<std::string>> VCardRawData::GetParasMap()
99 {
100     return parasMap_;
101 }
102 
103 } // namespace Telephony
104 } // namespace OHOS
105