Android-cuttlefish cvd tool
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
utils.h File Reference
#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <algorithm>
#include <initializer_list>
#include <optional>
#include <tuple>
#include <type_traits>
#include <teeui/error.h>
#include <teeui/log.h>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  teeui::Array< T, elements >
 
class  teeui::ByteBufferProxy
 
struct  teeui::ByteBufferProxy::has_data< T >
 
class  teeui::HMac< Impl >
 
struct  teeui::choose_hton< IntType, __ORDER_LITTLE_ENDIAN__ >
 
struct  teeui::choose_hton< IntType, __ORDER_BIG_ENDIAN__ >
 
struct  teeui::UnitT< unit >
 
struct  teeui::Add< Numeric >
 
struct  teeui::Sub< Numeric >
 
struct  teeui::Mul< Numeric >
 
struct  teeui::Div< Numeric >
 
struct  teeui::BinOp< T1, T2, Numeric, Op >
 
struct  teeui::MetaParam< Name, ParamType >
 
struct  teeui::MetaParam< Name, Coordinate< Unit, Numeric > >
 
class  teeui::Param< Name, ParamType >
 
class  teeui::Coordinate< Unit, Numeric >
 
struct  teeui::MetaList< T >
 
struct  teeui::metaParam2Param< MetaParam< ParamName, ParamType > >
 
struct  teeui::metaParam2ParamType< MetaParam< ParamName, ParamType > >
 
struct  teeui::isCoordinateType< T >
 
struct  teeui::isCoordinateType< Coordinate< Unit, Numeric > >
 
struct  teeui::isCoordinateParam< MetaParam< ParamName, ParamType > >
 
struct  teeui::isMetaParam< T >
 
struct  teeui::isMetaParam< MetaParam< ParamName, ParamType > >
 
class  teeui::context< MetaList< MetaParam< ParamsNames, ParamTypes >... >, Numeric >
 
class  teeui::context< MetaList< MetaParam< ParamsNames, ParamTypes >... >, Numeric >::Proxy
 
class  teeui::Vec2d< Coord >
 
class  teeui::ConvexObject< capacity >
 
class  teeui::Box< Coord >
 
struct  teeui::Event
 
struct  teeui::Callback< Ret(Args...)>
 
struct  teeui::CallbackHelper< Fn, Ret, Args >
 
struct  teeui::LayoutElement< Derived >
 
struct  teeui::MetaList2Layout< MetaList< Elements... > >
 
class  teeui::Range< Iterator >
 

Namespaces

namespace  teeui
 
namespace  teeui::bits
 

Macros

#define Position(x, y)
 
#define Dimension(w, h)
 
#define BEGIN_ELEMENT(name, type, ...)
 
#define END_ELEMENT()   }
 
#define DECLARE_TYPED_PARAMETER(name, type)
 
#define DECLARE_PARAMETER(name)   DECLARE_TYPED_PARAMETER(name, ::teeui::pxs)
 
#define CONSTANT(name, value)   static constexpr const auto name = value
 
#define BOTTOM_EDGE_OF(name)   (name::pos_y + name::dim_h)
 
#define CONVEX_OBJECT(...)   makeConvexObject(__VA_ARGS__)
 
#define CONVEX_OBJECTS(...)   std::make_tuple(__VA_ARGS__)
 
#define NEW_LAYOUT(name, ...)   using name = ::teeui::MetaList<__VA_ARGS__>
 
#define NEW_PARAMETER_SET(name, ...)   using name = ::teeui::MetaList<__VA_ARGS__>
 
#define LABELS(name, ...)   using ::teeui::MetaList<__VA_ARGS__>
 
#define TEXT_ID(textId)   static_cast<uint32_t>(textId)
 

Typedefs

using teeui::AuthTokenKey = Array< uint8_t, kAuthTokenKeySize >
 
using teeui::Hmac = AuthTokenKey
 
using teeui::px = UnitT< Unit::PX >
 
using teeui::dp = UnitT< Unit::DP >
 
using teeui::mm = UnitT< Unit::MM >
 
using teeui::DefaultNumericType = float
 
template<typename T1 , typename T2 , typename Numeric >
using teeui::add = BinOp< T1, T2, Numeric, Add >
 
template<typename T1 , typename T2 , typename Numeric >
using teeui::sub = BinOp< T1, T2, Numeric, Sub >
 
template<typename T1 , typename T2 , typename Numeric >
using teeui::mul = BinOp< T1, T2, Numeric, Mul >
 
template<typename T1 , typename T2 , typename Numeric >
using teeui::div = BinOp< T1, T2, Numeric, Div >
 
using teeui::dps = Coordinate< dp >
 
using teeui::mms = Coordinate< mm >
 
using teeui::pxs = Coordinate< px >
 
using teeui::Color = uint32_t
 
template<typename Coord >
using teeui::Point = Vec2d< Coord >
 
using teeui::PxPoint = Point< pxs >
 
using teeui::PxVec = Vec2d< pxs >
 
using teeui::CallbackEvent = Callback< Error(Event)>
 
using teeui::PixelDrawer = Callback< Error(uint32_t, uint32_t, Color)>
 
template<typename Fn >
using teeui::PixelDrawerHelper = CallbackHelper< Fn, Error, uint32_t, uint32_t, Color >
 
template<typename T >
using teeui::layout_t = typename MetaList2Layout< T >::type
 

Enumerations

enum class  teeui::Unit : uint8_t { teeui::PX , teeui::DP , teeui::MM }
 
enum class  teeui::EventType : uint8_t { teeui::KeyDown , teeui::KeyUp , teeui::KeyMoved }
 

Functions

template<typename T >
auto teeui::bytesCast (const T &v) -> const uint8_t(&)[sizeof(T)]
 
template<typename T >
auto teeui::bytesCast (T &v) -> uint8_t(&)[sizeof(T)]
 
bool teeui::operator== (const ByteBufferProxy &lhs, const ByteBufferProxy &rhs)
 
template<typename IntType >
IntType teeui::hton (const IntType &value)
 
template<typename IntType >
IntType teeui::ntoh (const IntType &value)
 
long double teeui::bits::abs (long double v)
 
double teeui::bits::abs (double v)
 
long double teeui::bits::ceil (long double v)
 
double teeui::bits::ceil (double v)
 
long double teeui::bits::floor (long double v)
 
double teeui::bits::floor (double v)
 
long double teeui::bits::sqrt (long double v)
 
double teeui::bits::sqrt (double v)
 
float teeui::bits::round (float v)
 
long double teeui::bits::round (long double v)
 
double teeui::bits::round (double v)
 
Color teeui::drawLinePoint (Point< pxs > a, Point< pxs > b, Point< pxs > px_origin, Color c, pxs width=pxs(1.0))
 
Color teeui::drawCirclePoint (Point< pxs > center, pxs r, Point< pxs > px_origin, Color c)
 
optional< PxPoint > teeui::intersect (const PxVec &a, const PxPoint &b, const PxVec &c, const PxPoint &d)
 
ssize_t teeui::bits::intersect (const PxPoint *oBegin, const PxPoint *oEnd, const PxPoint &lineA, const PxPoint &lineB, PxPoint *nBegin, PxPoint *nEnd)
 
pxs teeui::bits::area (const PxPoint *begin, const PxPoint *end)
 
template<typename Ret , typename... Args>
Callback< Ret(Args...)> teeui::makeCallback (Ret(*fn)(Args..., void *), void *priv_data)
 
template<typename Fn >
PixelDrawerHelper< Fn > teeui::makePixelDrawer (Fn fn)
 
template<typename... Elements, typename Context >
std::tuple< Elements... > teeui::instantiateLayout (MetaList< Elements... >, const Context &context)
 
template<typename... Coords>
constexpr std::tuple< Vec2d< Coords >... > teeui::makeConvexObject (const Vec2d< Coords > &... points)
 
template<size_t capacity, typename Tuple , typename Context , size_t... I>
constexpr ConvexObject< capacityteeui::initConvexObject (const Context &context, const Tuple &outline, std::index_sequence< I... >)
 
template<size_t capacity, typename... Points, typename Context >
constexpr ConvexObject< capacityteeui::initConvexObject (const Context &context, const std::tuple< Points... > &outline)
 
template<size_t capacity, typename Tuple , typename Context , size_t... I, size_t size>
constexpr void teeui::initConvexObjectArray (const Context &context, ConvexObject< capacity >(&out)[size], const Tuple &t, std::index_sequence< I... >)
 
template<size_t capacity, typename... COs, typename Context , size_t size>
constexpr void teeui::initConvexObjectArray (const Context &context, ConvexObject< capacity >(&out)[size], const std::tuple< COs... > &t)
 
template<typename Iterator >
Range< Iterator > teeui::makeRange (Iterator begin, Iterator end)
 

Variables

constexpr const uint8_t teeui::kAuthTokenKeySize = 32
 
constexpr const uint8_t teeui::kHmacKeySize = kAuthTokenKeySize
 
template<typename Unit >
constexpr const char * teeui::str = "N/A"
 
template<>
constexpr const char * teeui::str< px > = "px"
 
template<>
constexpr const char * teeui::str< dp > = "dp"
 
template<>
constexpr const char * teeui::str< mm > = "mm"
 
static constexpr const ssize_t teeui::bits::kIntersectEmpty = -1
 
static constexpr const ssize_t teeui::bits::kIntersectAllPositive = -2
 

Macro Definition Documentation

◆ BEGIN_ELEMENT

#define BEGIN_ELEMENT (   name,
  type,
  ... 
)
Value:
struct name : public type<name, ##__VA_ARGS__> { \
name() = default; \
template <typename Context> \
name(const Context& context) : type<name, ##__VA_ARGS__>(context) {}
uint8_t type
Definition: pairing_connection.h:0

◆ BOTTOM_EDGE_OF

#define BOTTOM_EDGE_OF (   name)    (name::pos_y + name::dim_h)

◆ CONSTANT

#define CONSTANT (   name,
  value 
)    static constexpr const auto name = value

◆ CONVEX_OBJECT

#define CONVEX_OBJECT (   ...)    makeConvexObject(__VA_ARGS__)

◆ CONVEX_OBJECTS

#define CONVEX_OBJECTS (   ...)    std::make_tuple(__VA_ARGS__)

◆ DECLARE_PARAMETER

#define DECLARE_PARAMETER (   name)    DECLARE_TYPED_PARAMETER(name, ::teeui::pxs)

◆ DECLARE_TYPED_PARAMETER

#define DECLARE_TYPED_PARAMETER (   name,
  type 
)
Value:
struct Param_##name {}; \
Definition: utils.h:298

◆ Dimension

#define Dimension (   w,
 
)
Value:
static const constexpr auto dim_w = w; \
static const constexpr auto dim_h = h

◆ END_ELEMENT

#define END_ELEMENT ( )    }

◆ LABELS

#define LABELS (   name,
  ... 
)    using ::teeui::MetaList<__VA_ARGS__>

◆ NEW_LAYOUT

#define NEW_LAYOUT (   name,
  ... 
)    using name = ::teeui::MetaList<__VA_ARGS__>

Creates a new Layout with the name "name" followed by a list of Layout elements as defined with BEGIN_ELEMENT(name).

◆ NEW_PARAMETER_SET

#define NEW_PARAMETER_SET (   name,
  ... 
)    using name = ::teeui::MetaList<__VA_ARGS__>

◆ Position

#define Position (   x,
 
)
Value:
static const constexpr auto pos_x = x; \
static const constexpr auto pos_y = y

◆ TEXT_ID

#define TEXT_ID (   textId)    static_cast<uint32_t>(textId)