Middle files are used to specify what messaging and serialization code the C++ Middleware Writer should output. Lines like the following are the basis of Middle code:
[ options ] (T1, T2, ...  Tn)
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 a closing brace (}) like this:
    -out (message_id_8, ::std::vector<int32_t>, ::std::string)
    -out (message_id_8, ::std::array)
    -out (message_id_8, ::plf::colony<::std::string>)

Based on that input, the C++ Middleware Writer (CMW) creates a send_messages namespace in a file called zz.send_messages.hh. Functions are created within the namespace for each of the lines with matching parentheses.

These are the available options:

 -out, -in, -noInline, -maxLength, -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 gets generated.

The noInline option indicates that a generated function should not be marked as inline. If you only include a generated header in one translation unit, it's safe to use noInline. This option may help reduce the size of your executables.

The maxLength option allows users to specify the maximum length for a message. If the length of the message exceeds the value specified, an exception will be thrown. If this option isn't used, the CMW supplies a default value of 10,000. Here's an example of how to use this option:


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)
  -out (bool, cmw::stringPlus)
, the following can be used:
  -out -yeaNay (bool, cmw::stringPlus)

. When yeaNay is used, the object(s) after the bool is only marshalled if the value of the bool is false. This option leads to less output from the CMW and smaller executable sizes.

By convention, Middle files have a .mdl suffix.

Don't be confused by the middle tier of the CMW. The middle, back and front tiers of the CMW use code that's been generated based on Middle files.

Use // to comment out a line of Middle code.