EnumType Class Reference

#include <Pt/Mcp/Type.h>

String schema restricted to a fixed set of values. More...

Inherits Type.

Public Types

enum  TypeId {
  Null = 0 ,
  Integer = 1 ,
  Number = 2 ,
  String = 3 ,
  Boolean = 4 ,
  Object = 5 ,
  Array = 6
}
 JSON Schema kind of a Type. More...

Public Member Functions

 EnumType ()
 Creates an enum schema with no values.
 ~EnumType ()
 Destroys the enum schema.
EnumTypeaddValue (const std::string &value)
 Adds value to the set of allowed strings.
const std::vector< std::string > & values () const
 Returns the allowed string values.
void toSchema (std::ostream &os, const std::string &description="") const override
 Writes this enum as a JSON Schema object to os.
TypeId typeId () const
 Returns the JSON Schema kind of this type.

Detailed Description

EnumType is a composed Type whose schema is a JSON string with an enum list. addValue() appends an allowed string. The type id is Type::String. The caller owns the enum type and must keep it alive while a tool names it.

Member Enumeration Documentation

◆ TypeId

enum TypeId
inherited
Enumerator
Null 

JSON null.

Integer 

JSON integer.

Number 

JSON number.

String 

JSON string.

Boolean 

JSON boolean.

Object 

JSON object.

Array 

JSON array.