-
Notifications
You must be signed in to change notification settings - Fork 4
/
middleFiles
61 lines (46 loc) · 2.12 KB
/
middleFiles
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
Middle files are used to specify what messaging and
serialization code the C++ Middleware Writer should output.
Lines like this:
[ options ] (T1, T2, ... Tn)
are the basis of Middle Code. Options start with a dash (-) symbol.
After any options, a list of C++ types is enclosed in a pair of
parentheses. One or more of these lines are wrapped by a name and
an exclamation point like this:
exampleMessages
-out (messageId, ::std::vector<int32_t>, ::std::string)
-out (messageId, ::std::array<float,3>)
-out (messageId, ::plf::colony<::std::string>)
!
Rather than repeating a message Id type for each message,
you can write the above like this:
exampleMessages <messageID_t=messageId>
-out (::std::vector<int32_t>, ::std::string)
-out (::std::array<float,3>)
-out (::plf::colony<::std::string>)
!
where "messageId" is the name of the type that you want to use
for message Ids.
Based on that input, the C++ Middleware Writer (CMW) creates
an exampleMessages struct in a file called {middle file name}.hh.
One or more functions are created within the struct for each of
the parenthesized lines of input.
The available options are: out, in and yeaNay.
The out and in options are used to tailor the output. If you
specify only -out, only a message-building/sending function is
generated. If you specify only -in, only a message-parsing/
receiving function is output.
The yeaNay option is used to support a messaging idiom where
a response to a request is a bool followed by optional data.
Rather than having two messages like this:
-out (bool) //Only used when bool is true
-out (bool,::std::string_view) //Only used when bool is false
, this can be used:
-out -yeaNay (::std::string_view)
. When yeaNay is used, the generated function first marshals a
bool based on the size of the string input. 'True' if it's
zero, 'false' otherwise. This option leads to less output
from the CMW.
By convention, Middle files have a .mdl suffix.
Don't be confused by the middle tier of the CMW. All of the tiers
of the CMW use code that's been generated based on Middle files.
Use // to comment out a line of Middle code.