#include <glog/logging.h>
#include <iostream>
#include <string>
#include "shaka/macros.h"
Go to the source code of this file.
|
#define | LOG_ONCE(severity) LOG_FIRST_N(severity, 1) |
|
#define | PRINTF_FORMAT(format, dots) |
|
#define | NO_SANITIZE(name) |
|
#define | FALL_THROUGH_INTENDED |
|
#define | BEGIN_ALLOW_COMPLEX_STATICS |
|
#define | END_ALLOW_COMPLEX_STATICS |
|
#define | MUST_USE_RESULT |
|
#define | DEFINE_ENUM_AND_TO_STRING_GENERIC_(Type, DEFINE_ENUM, ENUM_IMPL, CASE_IMPL) |
|
#define | DEFINE_ENUM_IMPL_(name) name, |
|
#define | DEFINE_CASE_IMPL_(name) case Enum::name: return #name; |
|
#define | DEFINE_ENUM_AND_TO_STRING(Type, DEFINE_ENUM) |
|
#define | DEFINE_ENUM_IMPL_2_(name, str) name, |
|
#define | DEFINE_CASE_IMPL_2_(name, str) case Enum::name: return str; |
|
#define | DEFINE_ENUM_AND_TO_STRING_2(Type, DEFINE_ENUM) |
|
§ BEGIN_ALLOW_COMPLEX_STATICS
#define BEGIN_ALLOW_COMPLEX_STATICS |
§ DEFINE_CASE_IMPL_
#define DEFINE_CASE_IMPL_ |
( |
|
name | ) |
case Enum::name: return #name; |
§ DEFINE_CASE_IMPL_2_
#define DEFINE_CASE_IMPL_2_ |
( |
|
name, |
|
|
|
str |
|
) |
| case Enum::name: return str; |
§ DEFINE_ENUM_AND_TO_STRING
#define DEFINE_ENUM_AND_TO_STRING |
( |
|
Type, |
|
|
|
DEFINE_ENUM |
|
) |
| |
Value:#define DEFINE_ENUM_IMPL_(name)
#define DEFINE_CASE_IMPL_(name)
#define DEFINE_ENUM_AND_TO_STRING_GENERIC_(Type, DEFINE_ENUM, ENUM_IMPL, CASE_IMPL)
Defines an enum type and a to_string method. This should be given the name of the type to define and a macro that defines the enum. The macro will be given another macro that should be called repeatedly with the enum to define.
Example:
#define OUR_DEFINE_ENUM(DEFINE) \
DEFINE(EnumValue) \
DEFINE(OtherValue)
Definition at line 89 of file macros.h.
§ DEFINE_ENUM_AND_TO_STRING_2
#define DEFINE_ENUM_AND_TO_STRING_2 |
( |
|
Type, |
|
|
|
DEFINE_ENUM |
|
) |
| |
Value:#define DEFINE_ENUM_IMPL_2_(name, str)
#define DEFINE_CASE_IMPL_2_(name, str)
#define DEFINE_ENUM_AND_TO_STRING_GENERIC_(Type, DEFINE_ENUM, ENUM_IMPL, CASE_IMPL)
- See also
- DEFINE_ENUM_AND_TO_STRING This is the same except that the macro given to DEFINE_ENUM should be called with two arguments: the enum name and the string value.
Example:
#define OUR_DEFINE_ENUM(DEFINE) \
DEFINE(EnumValue, "enum") \
DEFINE(OtherValue, "other")
Definition at line 107 of file macros.h.
§ DEFINE_ENUM_AND_TO_STRING_GENERIC_
#define DEFINE_ENUM_AND_TO_STRING_GENERIC_ |
( |
|
Type, |
|
|
|
DEFINE_ENUM, |
|
|
|
ENUM_IMPL, |
|
|
|
CASE_IMPL |
|
) |
| |
Value:enum class Type { DEFINE_ENUM(ENUM_IMPL) }; \
inline std::string
to_string(Type e) noexcept { \
using Enum = Type; \
switch (e) { \
DEFINE_ENUM(CASE_IMPL) \
default: \
LOG(FATAL) << "Unknown enum value " << static_cast<int>(e); \
} \
} \
inline std::ostream&
operator<<(std::ostream& os, Type e) { \
}
std::ostream & operator<<(std::ostream &os, const Error &error)
Definition at line 60 of file macros.h.
§ DEFINE_ENUM_IMPL_
§ DEFINE_ENUM_IMPL_2_
#define DEFINE_ENUM_IMPL_2_ |
( |
|
name, |
|
|
|
str |
|
) |
| name, |
§ END_ALLOW_COMPLEX_STATICS
#define END_ALLOW_COMPLEX_STATICS |
§ FALL_THROUGH_INTENDED
#define FALL_THROUGH_INTENDED |
§ LOG_ONCE
#define LOG_ONCE |
( |
|
severity | ) |
LOG_FIRST_N(severity, 1) |
§ MUST_USE_RESULT
§ NO_SANITIZE
#define NO_SANITIZE |
( |
|
name | ) |
|
§ PRINTF_FORMAT
#define PRINTF_FORMAT |
( |
|
format, |
|
|
|
dots |
|
) |
| |