proxygen
my Namespace Reference

Classes

struct  ColorError
 
struct  Dimensions
 

Enumerations

enum  SmallEnum
 
enum  Color { Color::Red, Color::Blue }
 
enum  ColorErrorCode { ColorErrorCode::INVALID_COLOR }
 

Functions

Expected< StringPiece, ConversionCodeparseTo (folly::StringPiece in, Dimensions &out)
 
template<class String >
void toAppend (const Dimensions &in, String *result)
 
size_t estimateSpaceNeeded (const Dimensions &in)
 
Expected< StringPiece, ConversionCodeparseTo (StringPiece in, SmallEnum &out)
 
template<class String >
void toAppend (SmallEnum, String *result)
 
ColorError makeConversionError (ColorErrorCode, StringPiece sp)
 
Expected< StringPiece, ColorErrorCodeparseTo (StringPiece in, Color &out) noexcept
 

Enumeration Type Documentation

enum my::Color
strong
Enumerator
Red 
Blue 

Definition at line 980 of file StringTest.cpp.

980  {
981  Red,
982  Blue,
983 };
enum my::ColorErrorCode
strong
Enumerator
INVALID_COLOR 

Definition at line 985 of file StringTest.cpp.

enum my::SmallEnum
strong

Definition at line 1248 of file ConvTest.cpp.

1248 {};

Function Documentation

size_t my::estimateSpaceNeeded ( const Dimensions in)

Definition at line 1243 of file ConvTest.cpp.

References folly::estimateSpaceNeeded(), my::Dimensions::h, and my::Dimensions::w.

1243  {
1244  return 2000 + folly::estimateSpaceNeeded(in.w) +
1246 }
constexpr std::enable_if< std::is_same< T, char >::value, size_t >::type estimateSpaceNeeded(T)
Definition: Conv.h:412
ColorError my::makeConversionError ( ColorErrorCode  ,
StringPiece  sp 
)

Definition at line 991 of file StringTest.cpp.

References folly::Range< Iter >::str().

991  {
992  return ColorError("Invalid my::Color representation : " + sp.str());
993 }
std::string str() const
Definition: Range.h:591
Expected<StringPiece, ColorErrorCode> my::parseTo ( StringPiece  in,
Color out 
)
noexcept

Definition at line 995 of file StringTest.cpp.

References folly::makeUnexpected().

997  {
998  if (in == "R") {
999  out = Color::Red;
1000  } else if (in == "B") {
1001  out = Color::Blue;
1002  } else {
1003  return makeUnexpected(ColorErrorCode::INVALID_COLOR);
1004  }
1005  return StringPiece(in.end(), in.end());
1006 }
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
constexpr Iter end() const
Definition: Range.h:455
Range< const char * > StringPiece

Definition at line 1230 of file ConvTest.cpp.

References my::Dimensions::h, parseTo(), folly::Range< Iter >::removePrefix(), and my::Dimensions::w.

1232  {
1233  return parseTo(in, out.w)
1234  .then([](StringPiece sp) { return sp.removePrefix("x"), sp; })
1235  .then([&](StringPiece sp) { return parseTo(sp, out.h); });
1236 }
bool removePrefix(const const_range_type &prefix)
Definition: Range.h:893
Expected< StringPiece, ConversionCode > parseTo(StringPiece in, SmallEnum &out)
Definition: ConvTest.cpp:1250
Expected<StringPiece, ConversionCode> my::parseTo ( StringPiece  in,
SmallEnum out 
)

Definition at line 1250 of file ConvTest.cpp.

References folly::makeUnexpected(), and folly::Range< Iter >::removePrefix().

Referenced by parseTo(), and TEST().

1250  {
1251  out = {};
1252  if (in == "SmallEnum") {
1253  return in.removePrefix(in), in;
1254  } else {
1255  return makeUnexpected(ConversionCode::STRING_TO_FLOAT_ERROR);
1256  }
1257 }
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
bool removePrefix(const const_range_type &prefix)
Definition: Range.h:893
template<class String >
void my::toAppend ( const Dimensions in,
String *  result 
)

Definition at line 1239 of file ConvTest.cpp.

References my::Dimensions::h, folly::toAppend(), and my::Dimensions::w.

1239  {
1240  folly::toAppend(in.w, 'x', in.h, result);
1241 }
void toAppend(char value, Tgt *result)
Definition: Conv.h:406
template<class String >
void my::toAppend ( SmallEnum  ,
String *  result 
)

Definition at line 1260 of file ConvTest.cpp.

References folly::toAppend().

Referenced by TEST(), and testVariadicTo().

1260  {
1261  folly::toAppend("SmallEnum", result);
1262 }
void toAppend(char value, Tgt *result)
Definition: Conv.h:406