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, ::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, -no_inline, -max_length, -yea_nay

The out and in options are used to tailor the output. If you specify just -out, only a message-building/sending function is generated. If you specify just -in, only a message-parsing/ receiving function gets generated. If you specify neither, both message-sending and message-receiving functions will be created.

The no_inline 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 no_inline. This option may help reduce the size of your executables.

The max_length 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 yea_nay option is used to support a common 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::string_plus)
, the following can be used:
  -out -yea_nay (bool, cmw::string_plus)

. When yea_nay 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 front, middle and back tiers use code that's been generated based on Middle files.

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