tree: 0d1dcbcfd1765b88f7fe9d72116ca0d06f8f7df7 [path history] [tgz]
  1. fidl/
  2. meta/
  3. test/
  6. fidl_types.h
  8. hex_dump.h
  10. indent.h
  11. OWNERS
  14. zx_types.h

fostr: Output Formatting

fostr is an ostream formatting library that provides the following:

  • support for indented formatting (indent.h)
  • hex dumps (hex_dump.h)
  • formatting for public/lib/fidl types (fidl_types.h)
  • formatting for zircon zx:: types (zx_types.h)
  • generated formatting for FIDL types

fostr is not part of the Fuchsia SDK.

FIDL type formatting

Currently, only structs, unions and enums can be formatted. Tables will be supported, and support for formatting serialized messages is also intended.

To use an existing formatter for FIDL types (say, for, add the dependency to your file, which will look like this:


Includes look like this:

#include "garnet/public/lib/fostr/fidl/fuchsia/foo/formatting.h"

Adding a new FIDL library is pretty simple: just add a new fostr/fidl/xxx subdirectory with a (see existing files for an example). The target must depend on the fostr/fidl targets for the libraries on which xxx depends. This means you may have to add formatting support for libraries that your FIDL library depends on.

If you have hand-rolled formatters for a library, they can be accommodated. Look for directories containing a file called ‘amendments.json’ for examples of this.

If you have formatters for all the types in your library, you can just provide a formatting.h and skip the amendments business. There are currently no examples of this.