• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include "system_defined_record.h"
17 
18 namespace OHOS {
19 namespace UDMF {
SystemDefinedRecord()20 SystemDefinedRecord::SystemDefinedRecord() : UnifiedRecord(SYSTEM_DEFINED_RECORD)
21 {
22 }
23 
GetSize()24 int64_t SystemDefinedRecord::GetSize()
25 {
26     return UnifiedDataUtils::GetDetailsSize(this->details_);
27 }
28 
AddProperty(const std::string & property,UDVariant & value)29 void SystemDefinedRecord::AddProperty(const std::string &property, UDVariant &value)
30 {
31     auto it = details_.find(property);
32     if (it == details_.end()) {
33         details_.insert(std::make_pair(property, value));
34     } else {
35         details_[property] = value;
36     }
37 }
38 
GetPropertyByName(const std::string & property) const39 UDVariant SystemDefinedRecord::GetPropertyByName(const std::string &property) const
40 {
41     auto it = details_.find(property);
42     if (it == details_.end()) {
43         return nullptr;
44     }
45     return it->second;
46 }
47 
SetDetails(UDDetails & details)48 void SystemDefinedRecord::SetDetails(UDDetails &details)
49 {
50     this->details_ = details;
51 }
52 
GetDetails() const53 UDDetails SystemDefinedRecord::GetDetails() const
54 {
55     return this->details_;
56 }
57 } // namespace UDMF
58 } // namespace OHOS