1 /*
2 * Copyright 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "storage/mutation_entry.h"
18
19 namespace bluetooth {
20 namespace storage {
21
MutationEntry(EntryType entry_type_param,PropertyType property_type_param,std::string section_param,std::string property_param,std::string value_param)22 MutationEntry::MutationEntry(EntryType entry_type_param, PropertyType property_type_param,
23 std::string section_param, std::string property_param,
24 std::string value_param)
25 : entry_type(entry_type_param),
26 property_type(property_type_param),
27 section(std::move(section_param)),
28 property(std::move(property_param)),
29 value(std::move(value_param)) {
30 switch (entry_type) {
31 case EntryType::SET:
32 log::assert_that(!section.empty(), "section cannot be empty for EntryType::SET");
33 log::assert_that(!property.empty(), "property cannot be empty for EntryType::SET");
34 log::assert_that(!value.empty(), "value cannot be empty for EntryType::SET");
35 break;
36 case EntryType::REMOVE_PROPERTY:
37 log::assert_that(!section.empty(), "section cannot be empty for EntryType::REMOVE_PROPERTY");
38 log::assert_that(!property.empty(),
39 "property cannot be empty for EntryType::REMOVE_PROPERTY");
40 break;
41 case EntryType::REMOVE_SECTION:
42 log::assert_that(!section.empty(), "section cannot be empty for EntryType::REMOVE_SECTION");
43 break;
44 // do not write a default case so that when a new enum is defined, compilation would fail
45 // automatically
46 }
47 }
48
49 } // namespace storage
50 } // namespace bluetooth
51