proxygen
wangle::StringCodec Class Reference

#include <StringCodec.h>

Inheritance diagram for wangle::StringCodec:
wangle::Handler< std::unique_ptr< folly::IOBuf >, std::string, std::string, std::unique_ptr< folly::IOBuf > > wangle::HandlerBase< HandlerContext< std::string, std::unique_ptr< folly::IOBuf > > >

Public Types

typedef Handler< std::unique_ptr< folly::IOBuf >, std::string, std::string, std::unique_ptr< folly::IOBuf > >::Context Context
 
- Public Types inherited from wangle::Handler< std::unique_ptr< folly::IOBuf >, std::string, std::string, std::unique_ptr< folly::IOBuf > >
typedef std::unique_ptr< folly::IOBufrin
 
typedef std::string rout
 
typedef std::string win
 
typedef std::unique_ptr< folly::IOBufwout
 
typedef HandlerContext< std::string, std::unique_ptr< folly::IOBuf > > Context
 

Public Member Functions

void read (Context *ctx, std::unique_ptr< folly::IOBuf > buf) override
 
folly::Future< folly::Unitwrite (Context *ctx, std::string msg) override
 
- Public Member Functions inherited from wangle::Handler< std::unique_ptr< folly::IOBuf >, std::string, std::string, std::unique_ptr< folly::IOBuf > >
 ~Handler () override=default
 
virtual void read (Context *ctx, std::unique_ptr< folly::IOBuf >msg)=0
 
virtual void readEOF (Context *ctx)
 
virtual void readException (Context *ctx, folly::exception_wrapper e)
 
virtual void transportActive (Context *ctx)
 
virtual void transportInactive (Context *ctx)
 
virtual folly::Future< folly::Unitwrite (Context *ctx, std::stringmsg)=0
 
virtual folly::Future< folly::UnitwriteException (Context *ctx, folly::exception_wrapper e)
 
virtual folly::Future< folly::Unitclose (Context *ctx)
 
- Public Member Functions inherited from wangle::HandlerBase< HandlerContext< std::string, std::unique_ptr< folly::IOBuf > > >
virtual ~HandlerBase ()=default
 
virtual void attachPipeline (HandlerContext< std::string, std::unique_ptr< folly::IOBuf > > *)
 
virtual void detachPipeline (HandlerContext< std::string, std::unique_ptr< folly::IOBuf > > *)
 
HandlerContext< std::string, std::unique_ptr< folly::IOBuf > > * getContext ()
 

Additional Inherited Members

- Static Public Attributes inherited from wangle::Handler< std::unique_ptr< folly::IOBuf >, std::string, std::string, std::unique_ptr< folly::IOBuf > >
static const HandlerDir dir
 

Detailed Description

Definition at line 26 of file StringCodec.h.

Member Typedef Documentation

Definition at line 31 of file StringCodec.h.

Member Function Documentation

void wangle::StringCodec::read ( Context ctx,
std::unique_ptr< folly::IOBuf buf 
)
inlineoverride

Definition at line 33 of file StringCodec.h.

References folly::IOBuf::coalesce(), data, folly::IOBuf::data(), and folly::IOBuf::length().

33  {
34  if (buf) {
35  buf->coalesce();
36  std::string data((const char*)buf->data(), buf->length());
37  ctx->fireRead(data);
38  }
39  }
ByteRange coalesce()
Definition: IOBuf.h:1095
const uint8_t * data() const
Definition: IOBuf.h:499
std::size_t length() const
Definition: IOBuf.h:533
const char * string
Definition: Conv.cpp:212
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
folly::Future<folly::Unit> wangle::StringCodec::write ( Context ctx,
std::string  msg 
)
inlineoverride

Definition at line 41 of file StringCodec.h.

References folly::IOBuf::copyBuffer(), and folly::gen::move.

41  {
42  auto buf = folly::IOBuf::copyBuffer(msg.data(), msg.length());
43  return ctx->fireWrite(std::move(buf));
44  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587

The documentation for this class was generated from the following file: