我想创建轻对象数据包以在客户端和服务器应用程序之间传递。
这是一个非常简单的任务,我可以只用一个字节来控制,所以一个字节中的每一位都会有不同的含义,
仅使用位
0 = False
1 = True
我现在需要的东西:
1 - Loaded from database
2 - Persisted
3 - Changed
4 - Marked to Delete
5 -
6 -
7 - Null Value
8 - Read Only
1) How do I use bit operators in Delphi to check each bit value?
2) How do I set the bit Values?
解决方案
在所有帮助之后,我将使用下一组
TStateType = (
stLoaded = 0, // loaded from persistance
stNative = 2, // value loaded and converted to native type
stPersisted = 3, // saved
stChanged = 4, // object or member changed
stToDelete = 5, // marked to delete
stReadOnly = 6, // read only object, will not allow changes
stNull = 7 // value is null
);
TState = Set of TStateType;
对于流 -> 持久性,这将是要使用的记录:
TDataPackage = record
Data: TBytes;
TypeInfo: TMetaInfo;
State: Byte;
Instance: TBuffer;
end;
谢谢大家,所有的答案和评论。