Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
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:
-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 lines with matching parentheses.
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 bool is passed as a template
argument and the remainder of the message is only marshalled if
the value of the bool is false. 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.