JSON Voorhees
Killer JSON for C++
tokenizer.hpp File Reference

A stream-based tokenizer meant to help with creating custom parsers. More...

#include <jsonv/config.hpp>
#include <jsonv/string_view.hpp>
#include <iosfwd>
#include <memory>
#include <vector>

Go to the source code of this file.

Classes

class  jsonv::tokenizer
 Splits input into tokens, allowing traversal of JSON without verification. More...
 
struct  jsonv::tokenizer::token
 A representation of what this tokenizer has. More...
 

Enumerations

enum  jsonv::token_kind : unsigned int {
  jsonv::token_kind::unknown = 0x00000, jsonv::token_kind::array_begin = 0x00001, jsonv::token_kind::array_end = 0x00002, jsonv::token_kind::boolean = 0x00004,
  jsonv::token_kind::null = 0x00008, jsonv::token_kind::number = 0x00010, jsonv::token_kind::separator = 0x00020, jsonv::token_kind::string = 0x00040,
  jsonv::token_kind::object_begin = 0x00080, jsonv::token_kind::object_key_delimiter = 0x00100, jsonv::token_kind::object_end = 0x00200, jsonv::token_kind::whitespace = 0x00400,
  jsonv::token_kind::comment = 0x00800, jsonv::token_kind::parse_error_indicator = 0x10000
}
 The kind of token that was encountered in a tokenizer. More...
 

Functions

constexpr token_kind jsonv::operator| (token_kind a, token_kind b)
 Combine multiple flag values. More...
 
constexpr token_kind jsonv::operator& (token_kind a, token_kind b)
 Filter out flag values. More...
 
constexpr token_kind jsonv::operator~ (token_kind a)
 Invert flag values. More...
 
JSONV_PUBLIC std::ostream & jsonv::operator<< (std::ostream &, const token_kind &)
 Output the given token_kind to the std::ostream. More...
 
JSONV_PUBLIC std::string jsonv::to_string (const token_kind &)
 Convert the given token_kind to an std::string. More...
 

Detailed Description

A stream-based tokenizer meant to help with creating custom parsers.

If you are happy with the JSON Voorhees AST (value and friends), it is probably easier to use the functions in jsonv/parse.hpp.

Copyright (c) 2014-2018 by Travis Gockel. All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the Apache License as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later version.

Author
Travis Gockel (travi.nosp@m.s@go.nosp@m.ckelh.nosp@m.ut.c.nosp@m.om)

Definition in file tokenizer.hpp.

Enumeration Type Documentation

enum jsonv::token_kind : unsigned int
strong

The kind of token that was encountered in a tokenizer.

The tokenizer will is parsing this information anyway, so it is easy to expose.

Definition at line 29 of file tokenizer.hpp.

Function Documentation

constexpr token_kind jsonv::operator& ( token_kind  a,
token_kind  b 
)

Filter out flag values.

Definition at line 70 of file tokenizer.hpp.

JSONV_PUBLIC std::ostream& jsonv::operator<< ( std::ostream &  ,
const token_kind  
)

Output the given token_kind to the std::ostream.

constexpr token_kind jsonv::operator| ( token_kind  a,
token_kind  b 
)

Combine multiple flag values.

Definition at line 64 of file tokenizer.hpp.

constexpr token_kind jsonv::operator~ ( token_kind  a)

Invert flag values.

Definition at line 76 of file tokenizer.hpp.

JSONV_PUBLIC std::string jsonv::to_string ( const token_kind )

Convert the given token_kind to an std::string.