Seismo-VLAB  1.3
An Open-Source Finite Element Software for Meso-Scale Simulations
RSJparser.hpp File Reference

This file contains the implementation of "A Ridiculously Simple JSON Parser for C++." This great parsing class was taken from http://subhrajit.net/. More...

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <unordered_map>
#include <utility>
#include <iostream>
#include <climits>
Include dependency graph for RSJparser.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  RSJresource
 
class  RSJparsedData
 

Macros

#define rsjObject   as<RSJobject>()
 
#define rsjArray   as<RSJarray>()
 
#define rsjAs(t)   as<t>()
 

Typedefs

typedef std::unordered_map< std::string, RSJresourceRSJobject
 
typedef std::vector< RSJresourceRSJarray
 

Enumerations

enum  RSJresourceType {
  RSJ_UNINITIATED, RSJ_UNKNOWN, RSJ_OBJECT, RSJ_ARRAY,
  RSJ_LEAF
}
 
enum  StrTrimDir { STRTRIM_L =1, STRTRIM_R =2, STRTRIM_LR =3 }
 

Functions

std::string to_string (RSJresourceType rt)
 
std::string strtrim (std::string str, std::string chars=" \\, int max_count=-1, StrTrimDir dirs=STRTRIM_LR)
 
std::string strip_outer_quotes (std::string str, char *qq=NULL)
 
int is_bracket (char c, std::vector< char const *> &bracks, int indx=0)
 
std::vector< std::string > split_RSJ_array (const std::string &str)
 
std::string insert_tab_after_newlines (std::string str)
 
int seek_next (std::string *str_p, int start_pos, char character)
 
template<>
std::string RSJresource::as< std::string > (const std::string &def)
 

Variables

static char const * RSJobjectbrackets = "{}"
 
static char const * RSJarraybrackets = "[]"
 
static char RSJobjectassignment = ':'
 
static char RSJarraydelimiter = ','
 
static std::vector< char const * > RSJbrackets = {RSJobjectbrackets, RSJarraybrackets}
 
static std::vector< char const * > RSJstringquotes = {"\"\"", "''"}
 
static char RSJcharescape = '\\'
 
static std::string RSJlinecommentstart = "//"
 
static std::string RSJprinttab = " "
 

Detailed Description

This file contains the implementation of "A Ridiculously Simple JSON Parser for C++." This great parsing class was taken from http://subhrajit.net/.

Author
Subhrajit Bhattacharya (http://subhrajit.net/)
Date
2018
Version
2.x
See also
main.cpp Driver.hpp

Macro Definition Documentation

◆ rsjArray

#define rsjArray   as<RSJarray>()

◆ rsjAs

#define rsjAs (   t)    as<t>()

◆ rsjObject

#define rsjObject   as<RSJobject>()

Typedef Documentation

◆ RSJarray

typedef std::vector<RSJresource> RSJarray

◆ RSJobject

typedef std::unordered_map<std::string,RSJresource> RSJobject

Enumeration Type Documentation

◆ RSJresourceType

Enumerator
RSJ_UNINITIATED 
RSJ_UNKNOWN 
RSJ_OBJECT 
RSJ_ARRAY 
RSJ_LEAF 

◆ StrTrimDir

enum StrTrimDir
Enumerator
STRTRIM_L 
STRTRIM_R 
STRTRIM_LR 

Function Documentation

◆ insert_tab_after_newlines()

std::string insert_tab_after_newlines ( std::string  str)
inline

◆ is_bracket()

int is_bracket ( char  c,
std::vector< char const *> &  bracks,
int  indx = 0 
)
inline

◆ RSJresource::as< std::string >()

template<>
std::string RSJresource::as< std::string > ( const std::string &  def)
inline

◆ seek_next()

int seek_next ( std::string *  str_p,
int  start_pos,
char  character 
)
inline

◆ split_RSJ_array()

std::vector<std::string> split_RSJ_array ( const std::string &  str)
inline

◆ strip_outer_quotes()

std::string strip_outer_quotes ( std::string  str,
char *  qq = NULL 
)
inline

◆ strtrim()

std::string strtrim ( std::string  str,
std::string  chars = " \t\n\r",
int  max_count = -1,
StrTrimDir  dirs = STRTRIM_LR 
)
inline

◆ to_string()

std::string to_string ( RSJresourceType  rt)
inline

Variable Documentation

◆ RSJarraybrackets

char const* RSJarraybrackets = "[]"
static

◆ RSJarraydelimiter

char RSJarraydelimiter = ','
static

◆ RSJbrackets

std::vector<char const*> RSJbrackets = {RSJobjectbrackets, RSJarraybrackets}
static

◆ RSJcharescape

char RSJcharescape = '\\'
static

◆ RSJlinecommentstart

std::string RSJlinecommentstart = "//"
static

◆ RSJobjectassignment

char RSJobjectassignment = ':'
static

◆ RSJobjectbrackets

char const* RSJobjectbrackets = "{}"
static

◆ RSJprinttab

std::string RSJprinttab = " "
static

◆ RSJstringquotes

std::vector<char const*> RSJstringquotes = {"\"\"", "''"}
static