Shaka Player Embedded
Macros
macros.h File Reference
#include <glog/logging.h>
#include <iostream>
#include <string>
#include "shaka/macros.h"

Go to the source code of this file.

Macros

#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)
 

Macro Definition Documentation

§ BEGIN_ALLOW_COMPLEX_STATICS

#define BEGIN_ALLOW_COMPLEX_STATICS

Definition at line 42 of file macros.h.

§ DEFINE_CASE_IMPL_

#define DEFINE_CASE_IMPL_ (   name)    case Enum::name: return #name;

Definition at line 76 of file macros.h.

§ DEFINE_CASE_IMPL_2_

#define DEFINE_CASE_IMPL_2_ (   name,
  str 
)    case Enum::name: return str;

Definition at line 94 of file macros.h.

§ DEFINE_ENUM_AND_TO_STRING

#define DEFINE_ENUM_AND_TO_STRING (   Type,
  DEFINE_ENUM 
)
Value:
#define DEFINE_ENUM_IMPL_(name)
Definition: macros.h:75
#define DEFINE_CASE_IMPL_(name)
Definition: macros.h:76
#define DEFINE_ENUM_AND_TO_STRING_GENERIC_(Type, DEFINE_ENUM, ENUM_IMPL, CASE_IMPL)
Definition: macros.h:60

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)
Definition: macros.h:93
#define DEFINE_CASE_IMPL_2_(name, str)
Definition: macros.h:94
#define DEFINE_ENUM_AND_TO_STRING_GENERIC_(Type, DEFINE_ENUM, ENUM_IMPL, CASE_IMPL)
Definition: macros.h:60
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) { \
return os << to_string(e); \
}
std::string to_string(VideoReadyState state)
Definition: media_player.cc:32
std::ostream & operator<<(std::ostream &os, const Error &error)
Definition: error.h:75

Definition at line 60 of file macros.h.

§ DEFINE_ENUM_IMPL_

#define DEFINE_ENUM_IMPL_ (   name)    name,

Definition at line 75 of file macros.h.

§ DEFINE_ENUM_IMPL_2_

#define DEFINE_ENUM_IMPL_2_ (   name,
  str 
)    name,

Definition at line 93 of file macros.h.

§ END_ALLOW_COMPLEX_STATICS

#define END_ALLOW_COMPLEX_STATICS

Definition at line 43 of file macros.h.

§ FALL_THROUGH_INTENDED

#define FALL_THROUGH_INTENDED

Definition at line 41 of file macros.h.

§ LOG_ONCE

#define LOG_ONCE (   severity)    LOG_FIRST_N(severity, 1)

Definition at line 25 of file macros.h.

§ MUST_USE_RESULT

#define MUST_USE_RESULT

Definition at line 52 of file macros.h.

§ NO_SANITIZE

#define NO_SANITIZE (   name)

Definition at line 40 of file macros.h.

§ PRINTF_FORMAT

#define PRINTF_FORMAT (   format,
  dots 
)

Definition at line 39 of file macros.h.