XRTraits C++ OpenXR Utilities
Main Page

Introduction

In this documentation:

General coding guidelines

The term "classes" and "types" in this section refer to class and struct types, class and struct type templates, and type aliases (created with the keyword using) that are not involved in compile-time meta-programming. Rephrased, those terms in this section refer to types that are intended for direct usage through instantiation, or through instantiation of a derived type. This also somewhat extends to naming of type-manipulation-related functions, such as the various "cast" functions: since they resemble functionality provided by the C++ standard implementation, they are named using a similar pattern to their standard counterparts, e.g. xrtraits::required_verified_cast<T>().

Handling of input OpenXR structures with type and next members is supported with verification and type-safety utilities, see the page on [Dynamic Typing and OpenXR Structs](TypeVerification) for details.

Loose coupling, high cohesion.

Avoid writing by hand things that can be generated from the specification. See the Python files under scripts/ for examples and starting places that use infrastructure developed for the loader to make code generation easier.

This is not intended to be a comprehensive "style guide". For those needs, see widely-used references such as "Effective Modern C++" by Scott Meyers (as well as the non-outdated recommendations from the earlier "Effective C++" books) and the C++ Core Guidelines.

In terms of bikeshed color, match the surroundings. It may help to humbly remember that maintaining code is roughly twice as difficult as writing it in the first place. Be kind to those who will follow you, potentially including your future self.

Use clang-format and git clang-format compulsively. Try not to push commits that would change if you formatted them. (git clang-format will only format the portions of files modified by staged changes, so it avoids "collateral damage" from formatting in code that might not be fully formatted. But, this is a young project so this shouldn't be as common of a concern until a new clang-format release makes our existing .clang-format file behave differently.)

Use the file-boilerplate tool when you want to create a new source or header file.

Mark "todos" as follows, so Doxygen and other tools can easily extract them:

/// @todo short description here

Check the Doxygen output from time to time during development to make sure it looks how you expected it to.

Naming

Copyright and License for this index.md page

For this page only:

Copyright 2018-2019 Collabora, Ltd.

SPDX-License-Identifier: BSL-1.0