MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Message

Class Message

LibLemon/include/lemon/ipc/message.h:21–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 using MessageRawDataObject = std::pair<uint8_t*, uint16_t>; // length, data
20
21 class Message final {
22 protected:
23 friend class Interface;
24 friend class Endpoint;
25 uint8_t* mdata;
26 private:
27 uint16_t msize;
28 uint64_t mid;
29
30 Message& operator=(const Message& m);
31
32 template<typename T>
33 uint16_t GetSize(const T& obj) const {
34 return sizeof(obj);
35 }
36
37 template<typename T>
38 void Insert(uint16_t& pos, const T& obj){
39 memcpy(&mdata[pos], &obj, sizeof(T));
40 pos += sizeof(T);
41 }
42
43 template<typename O>
44 long Decode(uint16_t& pos, O& o){
45 uint8_t* currentData = mdata + pos;
46
47 if(pos + sizeof(O) > msize){
48 return ErrorDecodeOutOfBounds;
49 }
50
51 o = *(O*)currentData;
52 pos += sizeof(O);
53
54 return 0;
55 }
56
57 template<typename O, typename ...T>
58 long Decode(uint16_t& pos, O& object, T&... objects){
59 if(long ret = Decode(pos, object); ret){
60 return ret;
61 }
62
63 if(long ret = Decode(pos, objects...); ret){
64 return ret;
65 }
66
67 return 0;
68 }
69 public:
70 enum {
71 OK,
72 ErrorDecodeOutOfBounds,
73 ErrorBufferNotInitialized,
74 };
75
76 template<typename T>
77 static MessageRawDataObject EncodeGenericData(const T* data, uint16_t length){
78 return MessageRawDataObject((uint8_t*)data, sizeof(T) * length);

Callers 11

AddWindowFunction · 0.50
RemoveWindowFunction · 0.50
SetWindowStateFunction · 0.50
ToggleMenuFunction · 0.50
CreateWindowMethod · 0.50
DestroyWindowMethod · 0.50
SetTitleMethod · 0.50
RelocateMethod · 0.50
ResizeMethod · 0.50
MinimizeMethod · 0.50
DisplayContextMenuMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected