work_tmp/property.h

146 lines
4.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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