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 #ifndef DOCUMENT_KEY_H
17 #define DOCUMENT_KEY_H
18 
19 #include <stdint.h>
20 #include <string>
21 
22 #include "rd_json_object.h"
23 
24 #define GRD_DOC_OID_TIME_SIZE 4
25 #define GRD_DOC_OID_INCREMENTAL_VALUE_SIZE 2
26 #define GRD_DOC_OID_SIZE (GRD_DOC_OID_TIME_SIZE + GRD_DOC_OID_INCREMENTAL_VALUE_SIZE)
27 #define GRD_DOC_OID_HEX_SIZE (GRD_DOC_OID_SIZE * 2)
28 #define GRD_DOC_ID_TYPE_SIZE 1
29 
30 namespace DocumentDB {
31 enum class DocIdType {
32     INT = 1,
33     STRING,
34 };
35 
36 struct DocKey {
37 public:
38     int32_t keySize;
39     std::string key;
40     uint8_t type;
41 };
42 
43 class DocumentKey {
44 public:
45     static int GetOidDocKey(DocKey &key);
46 };
47 } // namespace DocumentDB
48 #endif // DOCUMENT_KEY_H