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 #include "os/log.h"
20
21 namespace bluetooth {
22 namespace storage {
23
MutationEntry(EntryType entry_type_param,PropertyType property_type_param,std::string section_param,std::string property_param,std::string value_param)24 MutationEntry::MutationEntry(
25 EntryType entry_type_param,
26 PropertyType property_type_param,
27 std::string section_param,
28 std::string property_param,
29 std::string value_param)
30 : entry_type(entry_type_param),
31 property_type(property_type_param),
32 section(std::move(section_param)),
33 property(std::move(property_param)),
34 value(std::move(value_param)) {
35 switch (entry_type) {
36 case EntryType::SET:
37 ASSERT_LOG(!section.empty(), "section cannot be empty for EntryType::SET");
38 ASSERT_LOG(!property.empty(), "property cannot be empty for EntryType::SET");
39 ASSERT_LOG(!value.empty(), "value cannot be empty for EntryType::SET");
40 break;
41 case EntryType::REMOVE_PROPERTY:
42 ASSERT_LOG(!section.empty(), "section cannot be empty for EntryType::REMOVE_PROPERTY");
43 ASSERT_LOG(!property.empty(), "property cannot be empty for EntryType::REMOVE_PROPERTY");
44 break;
45 case EntryType::REMOVE_SECTION:
46 ASSERT_LOG(!section.empty(), "section cannot be empty for EntryType::REMOVE_SECTION");
47 break;
48 // do not write a default case so that when a new enum is defined, compilation would fail automatically
49 }
50 }
51
52 } // namespace storage
53 } // namespace bluetooth