1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*!The Treasure Box Library
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright (C) 2009 - 2017, TBOOX Open Source Group.
*
* @author ruki
* @file prefix.h
* @ingroup object
*
*/
#ifndef TB_OBJECT_PREFIX_H
#define TB_OBJECT_PREFIX_H
/* //////////////////////////////////////////////////////////////////////////////////////
* includes
*/
#include "../prefix.h"
#include "../xml/xml.h"
/* //////////////////////////////////////////////////////////////////////////////////////
* types
*/
/// the object type enum
typedef enum __tb_object_type_e
{
TB_OBJECT_TYPE_NONE = 0
, TB_OBJECT_TYPE_DATA = 1
, TB_OBJECT_TYPE_DATE = 2
, TB_OBJECT_TYPE_ARRAY = 3
, TB_OBJECT_TYPE_STRING = 4
, TB_OBJECT_TYPE_NUMBER = 5
, TB_OBJECT_TYPE_BOOLEAN = 6
, TB_OBJECT_TYPE_DICTIONARY = 7
, TB_OBJECT_TYPE_NULL = 8
, TB_OBJECT_TYPE_USER = 9 //!< the user defined type, ...
}tb_object_type_e;
/// the object flag enum
typedef enum __tb_object_flag_e
{
TB_OBJECT_FLAG_NONE = 0
, TB_OBJECT_FLAG_READONLY = 1
, TB_OBJECT_FLAG_SINGLETON = 2
}tb_object_flag_e;
/// the object format enum
typedef enum __tb_object_format_e
{
TB_OBJECT_FORMAT_NONE = 0x0000 //!< none
, TB_OBJECT_FORMAT_BIN = 0x0001 //!< the tbox binary format
, TB_OBJECT_FORMAT_BPLIST = 0x0002 //!< the bplist format for apple
, TB_OBJECT_FORMAT_XPLIST = 0x0003 //!< the xplist format for apple
, TB_OBJECT_FORMAT_XML = 0x0004 //!< the xml format
, TB_OBJECT_FORMAT_JSON = 0x0005 //!< the json format
, TB_OBJECT_FORMAT_MAXN = 0x000f //!< the format maxn
, TB_OBJECT_FORMAT_DEFLATE = 0x0100 //!< deflate?
}tb_object_format_e;
/// the object type
typedef struct __tb_object_t
{
/// the object flag
tb_uint8_t flag;
/// the object type
tb_uint16_t type;
/// the object reference count
tb_size_t refn;
/// the object private data
tb_cpointer_t priv;
/// the copy func
struct __tb_object_t* (*copy)(struct __tb_object_t* object);
/// the clear func
tb_void_t (*clear)(struct __tb_object_t* object);
/// the exit func
tb_void_t (*exit)(struct __tb_object_t* object);
}tb_object_t, *tb_object_ref_t;
#endif
|