c73e5e278ec4060386ba05058c3667583a03dda5
[platform/core/base/bundle.git] / src / bundle-internal.h
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
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 #ifndef BUNDLE_INTERNAL_H_
18 #define BUNDLE_INTERNAL_H_
19
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <vector>
24
25 #include "include/bundle.h"
26
27 #include "key-info-internal.h"
28
29 namespace tizen_base {
30 namespace internal {
31
32 static const char TAG_IMPORT_EXPORT_CHECK[] = "`zaybxcwdveuftgsh`";
33
34 class Bundle {
35  public:
36   enum Property {
37     Array = BUNDLE_TYPE_ARRAY,
38     Primitive = BUNDLE_TYPE_PRIMITIVE,
39     Measurable = BUNDLE_TYPE_MEASURABLE,
40   };
41
42   enum Type {
43     None = BUNDLE_TYPE_NONE,
44     Any = BUNDLE_TYPE_ANY,
45     String = BUNDLE_TYPE_STR,
46     StringArray = BUNDLE_TYPE_STR_ARRAY,
47     Byte = BUNDLE_TYPE_BYTE,
48     ByteArray = BUNDLE_TYPE_BYTE_ARRAY,
49   };
50
51   Bundle();
52   Bundle(unsigned char* raw, int size);
53   Bundle(int argc, char** argv);
54   virtual ~Bundle();
55
56   Bundle(const Bundle& b);
57   Bundle& operator = (const Bundle& b);
58   Bundle(Bundle&& b) noexcept;
59   Bundle& operator = (Bundle&& b) noexcept;
60
61   bool operator == (const Bundle& b);
62
63   void Remove(const std::string& key);
64   void Add(std::shared_ptr<KeyInfo> key_info);
65   void Set(const std::string& key, int index, std::vector<unsigned char> value);
66
67   std::shared_ptr<KeyInfo>& Get(const std::string& key);
68   int GetSize();
69   int GetType(const std::string& key);
70
71   unsigned char* Encode();
72   const std::map<std::string, std::shared_ptr<KeyInfo>>& GetMap();
73   std::vector<std::string> Export();
74
75  private:
76   int Decode(unsigned char* raw, int size);
77   int Import(int argc, char** argv);
78
79  private:
80   std::map<std::string, std::shared_ptr<KeyInfo>> map_;
81 };
82
83 }  // namespace internal
84 }  // namespace tizen_base
85
86 #endif  // BUNDLE_INTERNAL_H_