LLVM  8.0.1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
llvm::msgpack::ScalarNode Class Reference

A MessagePack scalar. More...

#include "llvm/BinaryFormat/MsgPackTypes.h"

Inheritance diagram for llvm::msgpack::ScalarNode:
Inheritance graph
[legend]
Collaboration diagram for llvm::msgpack::ScalarNode:
Collaboration graph
[legend]

Public Types

enum  ScalarKind {
  SK_Int, SK_UInt, SK_Nil, SK_Boolean,
  SK_Float, SK_String, SK_Binary
}
 
- Public Types inherited from llvm::msgpack::Node
enum  NodeKind { NK_Scalar, NK_Array, NK_Map }
 

Public Member Functions

 ScalarNode (int64_t IntValue)
 Construct an Int ScalarNode. More...
 
 ScalarNode (int32_t IntValue)
 Construct an Int ScalarNode. More...
 
 ScalarNode (uint64_t UIntValue)
 Construct an UInt ScalarNode. More...
 
 ScalarNode (uint32_t UIntValue)
 Construct an UInt ScalarNode. More...
 
 ScalarNode ()
 Construct a Nil ScalarNode. More...
 
 ScalarNode (bool BoolValue)
 Construct a Boolean ScalarNode. More...
 
 ScalarNode (double FloatValue)
 Construct a Float ScalarNode. More...
 
 ScalarNode (StringRef StringValue)
 Construct a String ScalarNode. More...
 
 ScalarNode (const char *StringValue)
 Construct a String ScalarNode. More...
 
 ScalarNode (std::string &&StringValue)
 Construct a String ScalarNode. More...
 
 ScalarNode (MemoryBufferRef BinaryValue)
 Construct a Binary ScalarNode. More...
 
 ~ScalarNode ()
 
ScalarNodeoperator= (const ScalarNode &RHS)=delete
 
ScalarNodeoperator= (ScalarNode &&RHS)
 A ScalarNode can only be move assigned. More...
 
void setScalarKind (ScalarKind SKind)
 Change the kind of this ScalarNode, zero initializing it to the new type. More...
 
ScalarKind getScalarKind ()
 Get the current kind of ScalarNode. More...
 
int64_t getInt ()
 Get the value of an Int scalar. More...
 
uint64_t getUInt ()
 Get the value of a UInt scalar. More...
 
bool getBool ()
 Get the value of an Boolean scalar. More...
 
double getFloat ()
 Get the value of an Float scalar. More...
 
StringRef getString ()
 Get the value of a String scalar. More...
 
StringRef getBinary ()
 Get the value of a Binary scalar. More...
 
void write (Writer &MPWriter) override
 Write to a MessagePack writer MPWriter. More...
 
StringRef inputYAML (StringRef ScalarStr)
 Parse a YAML scalar of the current ScalarKind from ScalarStr. More...
 
void outputYAML (raw_ostream &OS) const
 Output a YAML scalar of the current ScalarKind into OS. More...
 
yaml::QuotingType mustQuoteYAML (StringRef ScalarStr) const
 Determine which YAML quoting type the current value would need when output. More...
 
StringRef getYAMLTag () const
 Get the YAML tag for the current ScalarKind. More...
 
- Public Member Functions inherited from llvm::msgpack::Node
NodeKind getKind () const
 
 Node (NodeKind Kind)
 Construct a Node. Used by derived classes to track kind information. More...
 
virtual ~Node ()=default
 

Static Public Member Functions

static bool classof (const Node *N)
 
- Static Public Member Functions inherited from llvm::msgpack::Node
static Expected< OptNodePtrread (Reader &MPReader)
 Read from a MessagePack reader MPReader, returning an error if one is encountered, or None if MPReader is at the end of stream, or some Node pointer if some type is read. More...
 

Public Attributes

bool IgnoreTag = false
 Flag which affects how the type handles YAML tags when reading and writing. More...
 
int64_t IntValue
 
uint64_t UIntValue
 
bool BoolValue
 
double FloatValue
 
std::string StringValue
 

Static Public Attributes

static const charIntTag = "!int"
 
static const charNilTag = "!nil"
 
static const charBooleanTag = "!bool"
 
static const charFloatTag = "!float"
 
static const charStringTag = "!str"
 
static const charBinaryTag = "!bin"
 

Detailed Description

A MessagePack scalar.

Definition at line 72 of file MsgPackTypes.h.

Member Enumeration Documentation

◆ ScalarKind

Enumerator
SK_Int 
SK_UInt 
SK_Nil 
SK_Boolean 
SK_Float 
SK_String 
SK_Binary 

Definition at line 74 of file MsgPackTypes.h.

Constructor & Destructor Documentation

◆ ScalarNode() [1/11]

ScalarNode::ScalarNode ( int64_t  IntValue)

Construct an Int ScalarNode.

Definition at line 123 of file MsgPackTypes.cpp.

◆ ScalarNode() [2/11]

ScalarNode::ScalarNode ( int32_t  IntValue)

Construct an Int ScalarNode.

Definition at line 126 of file MsgPackTypes.cpp.

◆ ScalarNode() [3/11]

ScalarNode::ScalarNode ( uint64_t  UIntValue)

Construct an UInt ScalarNode.

Definition at line 129 of file MsgPackTypes.cpp.

References IntValue, and ScalarNode().

◆ ScalarNode() [4/11]

llvm::msgpack::ScalarNode::ScalarNode ( uint32_t  UIntValue)

Construct an UInt ScalarNode.

◆ ScalarNode() [5/11]

ScalarNode::ScalarNode ( )

Construct a Nil ScalarNode.

Definition at line 135 of file MsgPackTypes.cpp.

Referenced by ScalarNode().

◆ ScalarNode() [6/11]

ScalarNode::ScalarNode ( bool  BoolValue)

Construct a Boolean ScalarNode.

Definition at line 137 of file MsgPackTypes.cpp.

◆ ScalarNode() [7/11]

ScalarNode::ScalarNode ( double  FloatValue)

Construct a Float ScalarNode.

Definition at line 140 of file MsgPackTypes.cpp.

◆ ScalarNode() [8/11]

ScalarNode::ScalarNode ( StringRef  StringValue)

Construct a String ScalarNode.

Definition at line 143 of file MsgPackTypes.cpp.

References StringValue.

◆ ScalarNode() [9/11]

ScalarNode::ScalarNode ( const char StringValue)

Construct a String ScalarNode.

Definition at line 148 of file MsgPackTypes.cpp.

◆ ScalarNode() [10/11]

ScalarNode::ScalarNode ( std::string &&  StringValue)

Construct a String ScalarNode.

Definition at line 151 of file MsgPackTypes.cpp.

References StringValue.

◆ ScalarNode() [11/11]

ScalarNode::ScalarNode ( MemoryBufferRef  BinaryValue)

Construct a Binary ScalarNode.

Definition at line 156 of file MsgPackTypes.cpp.

References llvm::MemoryBufferRef::getBuffer(), and StringValue.

◆ ~ScalarNode()

ScalarNode::~ScalarNode ( )

Definition at line 161 of file MsgPackTypes.cpp.

Member Function Documentation

◆ classof()

static bool llvm::msgpack::ScalarNode::classof ( const Node N)
inlinestatic

◆ getBinary()

StringRef llvm::msgpack::ScalarNode::getBinary ( )
inline

Get the value of a Binary scalar.

Warning
Assumes getScalarKind() == SK_Binary

Definition at line 202 of file MsgPackTypes.h.

References assert().

◆ getBool()

bool llvm::msgpack::ScalarNode::getBool ( )
inline

Get the value of an Boolean scalar.

Warning
Assumes getScalarKind() == SK_Boolean

Definition at line 178 of file MsgPackTypes.h.

References assert().

◆ getFloat()

double llvm::msgpack::ScalarNode::getFloat ( )
inline

Get the value of an Float scalar.

Warning
Assumes getScalarKind() == SK_Float

Definition at line 186 of file MsgPackTypes.h.

References assert().

◆ getInt()

int64_t llvm::msgpack::ScalarNode::getInt ( )
inline

Get the value of an Int scalar.

Warning
Assumes getScalarKind() == SK_Int

Definition at line 162 of file MsgPackTypes.h.

References assert().

◆ getScalarKind()

ScalarKind llvm::msgpack::ScalarNode::getScalarKind ( )
inline

Get the current kind of ScalarNode.

Definition at line 157 of file MsgPackTypes.h.

◆ getString()

StringRef llvm::msgpack::ScalarNode::getString ( )
inline

Get the value of a String scalar.

Warning
Assumes getScalarKind() == SK_String

Definition at line 194 of file MsgPackTypes.h.

References assert().

◆ getUInt()

uint64_t llvm::msgpack::ScalarNode::getUInt ( )
inline

Get the value of a UInt scalar.

Warning
Assumes getScalarKind() == SK_UInt

Definition at line 170 of file MsgPackTypes.h.

References assert().

◆ getYAMLTag()

StringRef ScalarNode::getYAMLTag ( ) const

Get the YAML tag for the current ScalarKind.

Definition at line 259 of file MsgPackTypes.cpp.

References BinaryTag, BooleanTag, FloatTag, IntTag, llvm_unreachable, NilTag, SK_Binary, SK_Boolean, SK_Float, SK_Int, SK_Nil, SK_String, SK_UInt, and StringTag.

Referenced by llvm::yaml::TaggedScalarTraits< msgpack::ScalarNode >::output().

◆ inputYAML()

StringRef ScalarNode::inputYAML ( StringRef  ScalarStr)

Parse a YAML scalar of the current ScalarKind from ScalarStr.

Returns
An empty string on success, otherwise an error message.

Definition at line 189 of file MsgPackTypes.cpp.

References BoolValue, FloatValue, llvm_unreachable, SK_Binary, SK_Boolean, SK_Float, SK_Int, SK_Nil, SK_String, SK_UInt, StringValue, and UIntValue.

Referenced by llvm::yaml::TaggedScalarTraits< msgpack::ScalarNode >::input().

◆ mustQuoteYAML()

yaml::QuotingType ScalarNode::mustQuoteYAML ( StringRef  ScalarStr) const

Determine which YAML quoting type the current value would need when output.

Definition at line 233 of file MsgPackTypes.cpp.

References BinaryTag, BooleanTag, FloatTag, IntTag, llvm_unreachable, NilTag, SK_Binary, SK_Boolean, SK_Float, SK_Int, SK_Nil, SK_String, SK_UInt, and StringTag.

Referenced by llvm::yaml::TaggedScalarTraits< msgpack::ScalarNode >::mustQuote().

◆ operator=() [1/2]

ScalarNode& llvm::msgpack::ScalarNode::operator= ( const ScalarNode RHS)
delete

◆ operator=() [2/2]

ScalarNode & ScalarNode::operator= ( ScalarNode &&  RHS)

A ScalarNode can only be move assigned.

Definition at line 163 of file MsgPackTypes.cpp.

References BoolValue, FloatValue, SK_Binary, SK_Boolean, SK_Float, SK_Int, SK_Nil, SK_String, SK_UInt, StringValue, and UIntValue.

◆ outputYAML()

void ScalarNode::outputYAML ( raw_ostream OS) const

Output a YAML scalar of the current ScalarKind into OS.

Definition at line 209 of file MsgPackTypes.cpp.

References BoolValue, FloatValue, SK_Binary, SK_Boolean, SK_Float, SK_Int, SK_Nil, SK_String, SK_UInt, StringValue, and UIntValue.

Referenced by llvm::yaml::TaggedScalarTraits< msgpack::ScalarNode >::output().

◆ setScalarKind()

void llvm::msgpack::ScalarNode::setScalarKind ( ScalarKind  SKind)
inline

Change the kind of this ScalarNode, zero initializing it to the new type.

Definition at line 130 of file MsgPackTypes.h.

Referenced by llvm::yaml::TaggedScalarTraits< msgpack::ScalarNode >::input().

◆ write()

void ScalarNode::write ( Writer MPWriter)
overridevirtual

Member Data Documentation

◆ BinaryTag

const char * ScalarNode::BinaryTag = "!bin"
static

◆ BooleanTag

const char * ScalarNode::BooleanTag = "!bool"
static

◆ BoolValue

bool llvm::msgpack::ScalarNode::BoolValue

Definition at line 94 of file MsgPackTypes.h.

Referenced by inputYAML(), operator=(), outputYAML(), and write().

◆ FloatTag

const char * ScalarNode::FloatTag = "!float"
static

◆ FloatValue

double llvm::msgpack::ScalarNode::FloatValue

Definition at line 95 of file MsgPackTypes.h.

Referenced by inputYAML(), operator=(), outputYAML(), and write().

◆ IgnoreTag

bool llvm::msgpack::ScalarNode::IgnoreTag = false

Flag which affects how the type handles YAML tags when reading and writing.

When false, tags are used when reading and writing. When reading, the tag is used to decide the ScalarKind before parsing. When writing, the tag is output along with the value.

When true, tags are ignored when reading and writing. When reading, the ScalarKind is always assumed to be String. When writing, the tag is not output.

Definition at line 236 of file MsgPackTypes.h.

Referenced by llvm::yaml::TaggedScalarTraits< msgpack::ScalarNode >::input(), and llvm::yaml::TaggedScalarTraits< msgpack::ScalarNode >::output().

◆ IntTag

const char * ScalarNode::IntTag = "!int"
static

◆ IntValue

int64_t llvm::msgpack::ScalarNode::IntValue

Definition at line 92 of file MsgPackTypes.h.

Referenced by ScalarNode().

◆ NilTag

const char * ScalarNode::NilTag = "!nil"
static

◆ StringTag

const char * ScalarNode::StringTag = "!str"
static

◆ StringValue

std::string llvm::msgpack::ScalarNode::StringValue

Definition at line 96 of file MsgPackTypes.h.

Referenced by inputYAML(), operator=(), outputYAML(), ScalarNode(), and write().

◆ UIntValue

uint64_t llvm::msgpack::ScalarNode::UIntValue

Definition at line 93 of file MsgPackTypes.h.

Referenced by inputYAML(), operator=(), outputYAML(), and write().


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