work_tmp/property.h

146 lines
4.1 KiB
C
Raw Normal View History

2024-02-07 06:42:32 +00:00
#ifndef __PROFILE_H
#define __PROFILE_H
#ifndef PROPERTY_PROVIDER_MAX
#define PROPERTY_PROVIDER_MAX 2
#endif
#define PROPERTY_STORE_MAX 32
#define PROPERTY_KEY_MAX 64
#define PROPERTY_ID_MAX 24
#define PROPERTY_LINE_MAX 80
#ifndef INT8U
#define BOOL unsigned char
#define INT8U unsigned char
#define INT8S char
#define INT16U unsigned short
#define INT16S short
#define INT32U unsigned int
#define INT32S int
#define INT64U unsigned long long
#define INT64S long long
#define FP32 float
#define FP64 double
#endif
#if !defined(TRUE)
#define TRUE 1
#define FALSE 0
#endif // TRUE
#if !defined(PI)
#define PI 3.14159
#endif // PI
/*
config
*/
#define PROPERTY_PROV_FS_EN 1
#define PROPERTY_PROV_REMOTE_EN 0
typedef enum {
VT_UI4 = 0,
VT_I4 = 1,
VT_UI2 = 2,
VT_I2 = 3,
VT_UI1 = 4,
VT_I1 = 5,
VT_R4 = 6,
VT_STR = 7,
VT_NULL = 8,
VT_BIT4 = 9
} ValueType;
typedef enum {
PropertyTypeFS = 1,
PropertyTypeRemote = 2
} PropertyProviderType;
typedef struct {
struct {
INT8U cache : 1;
INT8U prefetch : 1;
} config;
PropertyProviderType type;
const char* id;
INT32U destId; // use when PropertyTypeRemote
} PropertyInitParam;
//属性除数
typedef struct {
const char* key;
ValueType type;
union {
INT32S i4;
INT16S i2;
INT8S i1;
INT32U ui4;
INT16U ui2;
INT8U ui1;
FP32 r4;
const char* str;
struct {
INT32U val;
INT32U mask;
} bit4;
} value;
INT8U success : 1;
} PropertyItem;
/* 搜索引擎初始化 -- 以下函数调用前必须先以此函数进行初始化
*/
INT32U PropertyInit(INT32U providerId, const PropertyInitParam* param);
/**
* key必须以大写或小写字母开头, , , .-_[], key大小写敏感
*/
INT32U GetProperty(INT32U providerId, const char* store, const char* id, const char* key, BOOL tryLocal, char* value, INT32U sizeOfValue, BOOL* isLocal);
INT32U SetProperty(INT32U providerId, const char* store, const char* id, const char* key, const char* value);
INT32U SetPropertyList(INT32U providerId, const char* store, const char* id, PropertyItem* list, INT32U count);
/* 获取对应类型的变量值
providerId 0PROPERTY_PROV_ID
store
key
tryLocal
defaultValue
retCode 0
isLocal
*/
INT32S GetInteger(INT32U providerId, const char* store, const char* key, BOOL tryLocal, INT32S defaultValue, INT32U* retCode, BOOL* isLocal);
INT32U GetUnsigned(INT32U providerId, const char* store, const char* key, BOOL tryLocal, INT32U defaultValue, INT32U* retCode, BOOL* isLocal);
FP32 GetFloat(INT32U providerId, const char* store, const char* key, BOOL tryLocal, FP32 defaultValue, INT32U* retCode, BOOL* isLocal);
BOOL GetBoolean(INT32U providerId, const char* store, const char* key, BOOL tryLocal, BOOL defaultValue, INT32U* retCode, BOOL* isLocal);
/* 设置变量值
providerId 0PROPERTY_PROV_ID
store
key
value
mask value的掩码SetBits()
INT32U 0
*/
INT32U SetInteger(INT32U providerId, const char* store, const char* key, INT32S value);
INT32U SetUnsigned(INT32U providerId, const char* store, const char* key, INT32U value);
INT32U SetFloat(INT32U providerId, const char* store, const char* key, FP32 value);
INT32U SetBits(INT32U providerId, const char* store, const char* key, INT32U value, INT32U mask);
INT32U ClearPropertyCache(INT32U providerId, const char* store, const char* id);
//INT32U VerifyPropertyCache(INT32U providerId);
/*
caseId:
1:
*/
INT32U SetPropertyTestCase(INT32U caseId);
#endif