ONE - On-device Neural Engine
Loading...
Searching...
No Matches
flatbuffers::ToStringVisitor Struct Reference

#include <minireflect.h>

Collaboration diagram for flatbuffers::ToStringVisitor:

Public Member Functions

 ToStringVisitor (std::string delimiter, bool quotes, std::string indent, bool vdelimited=true)
 
 ToStringVisitor (std::string delimiter)
 
void append_indent ()
 
void StartSequence ()
 
void EndSequence ()
 
void Field (size_t, size_t set_idx, ElementaryType, bool, const TypeTable *, const char *name, const uint8_t *val)
 
template<typename T >
void Named (T x, const char *name)
 
void UType (uint8_t x, const char *name)
 
void Bool (bool x)
 
void Char (int8_t x, const char *name)
 
void UChar (uint8_t x, const char *name)
 
void Short (int16_t x, const char *name)
 
void UShort (uint16_t x, const char *name)
 
void Int (int32_t x, const char *name)
 
void UInt (uint32_t x, const char *name)
 
void Long (int64_t x)
 
void ULong (uint64_t x)
 
void Float (float x)
 
void Double (double x)
 
void String (const struct String *str)
 
void Unknown (const uint8_t *)
 
void StartVector ()
 
void EndVector ()
 
void Element (size_t i, ElementaryType, const TypeTable *, const uint8_t *)
 
- Public Member Functions inherited from flatbuffers::IterationVisitor
virtual void String (const String *)
 
virtual ~IterationVisitor ()
 

Data Fields

std::string s
 
std::string d
 
bool q
 
std::string in
 
size_t indent_level
 
bool vector_delimited
 

Detailed Description

Definition at line 296 of file minireflect.h.

Constructor & Destructor Documentation

◆ ToStringVisitor() [1/2]

flatbuffers::ToStringVisitor::ToStringVisitor ( std::string  delimiter,
bool  quotes,
std::string  indent,
bool  vdelimited = true 
)
inline

Definition at line 303 of file minireflect.h.

305 : d(delimiter),
306 q(quotes),
307 in(indent),
308 indent_level(0),
309 vector_delimited(vdelimited) {}

◆ ToStringVisitor() [2/2]

flatbuffers::ToStringVisitor::ToStringVisitor ( std::string  delimiter)
inline

Definition at line 310 of file minireflect.h.

311 : d(delimiter),
312 q(false),
313 in(""),
314 indent_level(0),
315 vector_delimited(true) {}

Member Function Documentation

◆ append_indent()

void flatbuffers::ToStringVisitor::append_indent ( )
inline

Definition at line 317 of file minireflect.h.

317 {
318 for (size_t i = 0; i < indent_level; i++) { s += in; }
319 }

References in, indent_level, and s.

Referenced by Element(), EndSequence(), EndVector(), Field(), and StartVector().

◆ Bool()

void flatbuffers::ToStringVisitor::Bool ( bool  x)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 358 of file minireflect.h.

358{ s += x ? "true" : "false"; }

References s.

◆ Char()

void flatbuffers::ToStringVisitor::Char ( int8_t  x,
const char *  name 
)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 359 of file minireflect.h.

359{ Named(x, name); }
void Named(T x, const char *name)

References Named().

◆ Double()

void flatbuffers::ToStringVisitor::Double ( double  x)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 368 of file minireflect.h.

368{ s += NumToString(x); }
std::string NumToString(T t)
Definition util.h:128

References flatbuffers::NumToString(), and s.

◆ Element()

void flatbuffers::ToStringVisitor::Element ( size_t  i,
ElementaryType  ,
const TypeTable ,
const uint8_t *   
)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 393 of file minireflect.h.

394 {
395 if (i) {
396 s += ",";
397 if (vector_delimited) {
398 s += d;
400 } else {
401 s += " ";
402 }
403 }
404 }

References append_indent(), d, s, and vector_delimited.

◆ EndSequence()

void flatbuffers::ToStringVisitor::EndSequence ( )
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 326 of file minireflect.h.

326 {
327 s += d;
328 indent_level--;
330 s += "}";
331 }

References append_indent(), d, indent_level, and s.

◆ EndVector()

void flatbuffers::ToStringVisitor::EndVector ( )
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 383 of file minireflect.h.

383 {
384 if (vector_delimited) {
385 s += d;
386 indent_level--;
388 } else {
389 s += " ";
390 }
391 s += "]";
392 }

References append_indent(), d, indent_level, s, and vector_delimited.

◆ Field()

void flatbuffers::ToStringVisitor::Field ( size_t  ,
size_t  set_idx,
ElementaryType  ,
bool  ,
const TypeTable ,
const char *  name,
const uint8_t *  val 
)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 332 of file minireflect.h.

334 {
335 if (!val) return;
336 if (set_idx) {
337 s += ",";
338 s += d;
339 }
341 if (name) {
342 if (q) s += "\"";
343 s += name;
344 if (q) s += "\"";
345 s += ": ";
346 }
347 }
name
Definition setup.py:158

References append_indent(), d, q, and s.

◆ Float()

void flatbuffers::ToStringVisitor::Float ( float  x)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 367 of file minireflect.h.

367{ s += NumToString(x); }

References flatbuffers::NumToString(), and s.

◆ Int()

void flatbuffers::ToStringVisitor::Int ( int32_t  x,
const char *  name 
)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 363 of file minireflect.h.

363{ Named(x, name); }

References Named().

◆ Long()

void flatbuffers::ToStringVisitor::Long ( int64_t  x)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 365 of file minireflect.h.

365{ s += NumToString(x); }

References flatbuffers::NumToString(), and s.

◆ Named()

template<typename T >
void flatbuffers::ToStringVisitor::Named ( x,
const char *  name 
)
inline

Definition at line 348 of file minireflect.h.

348 {
349 if (name) {
350 if (q) s += "\"";
351 s += name;
352 if (q) s += "\"";
353 } else {
354 s += NumToString(x);
355 }
356 }

References flatbuffers::NumToString(), q, and s.

Referenced by Char(), Int(), Short(), UChar(), UInt(), UShort(), and UType().

◆ Short()

void flatbuffers::ToStringVisitor::Short ( int16_t  x,
const char *  name 
)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 361 of file minireflect.h.

361{ Named(x, name); }

References Named().

◆ StartSequence()

void flatbuffers::ToStringVisitor::StartSequence ( )
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 321 of file minireflect.h.

321 {
322 s += "{";
323 s += d;
324 indent_level++;
325 }

References d, indent_level, and s.

◆ StartVector()

void flatbuffers::ToStringVisitor::StartVector ( )
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 373 of file minireflect.h.

373 {
374 s += "[";
375 if (vector_delimited) {
376 s += d;
377 indent_level++;
379 } else {
380 s += " ";
381 }
382 }

References append_indent(), d, indent_level, s, and vector_delimited.

◆ String()

void flatbuffers::ToStringVisitor::String ( const struct String str)
inline

Definition at line 369 of file minireflect.h.

369 {
370 EscapeString(str->c_str(), str->size(), &s, true, false);
371 }
bool EscapeString(const char *s, size_t length, std::string *_text, bool allow_non_utf8, bool natural_utf8)
Definition util.h:594
str
Definition infer.py:18

References flatbuffers::EscapeString(), and s.

◆ UChar()

void flatbuffers::ToStringVisitor::UChar ( uint8_t  x,
const char *  name 
)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 360 of file minireflect.h.

360{ Named(x, name); }

References Named().

◆ UInt()

void flatbuffers::ToStringVisitor::UInt ( uint32_t  x,
const char *  name 
)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 364 of file minireflect.h.

364{ Named(x, name); }

References Named().

◆ ULong()

void flatbuffers::ToStringVisitor::ULong ( uint64_t  x)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 366 of file minireflect.h.

366{ s += NumToString(x); }

References flatbuffers::NumToString(), and s.

◆ Unknown()

void flatbuffers::ToStringVisitor::Unknown ( const uint8_t *  )
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 372 of file minireflect.h.

372{ s += "(?)"; }

References s.

◆ UShort()

void flatbuffers::ToStringVisitor::UShort ( uint16_t  x,
const char *  name 
)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 362 of file minireflect.h.

362{ Named(x, name); }

References Named().

◆ UType()

void flatbuffers::ToStringVisitor::UType ( uint8_t  x,
const char *  name 
)
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 357 of file minireflect.h.

357{ Named(x, name); }

References Named().

Field Documentation

◆ d

std::string flatbuffers::ToStringVisitor::d

Definition at line 298 of file minireflect.h.

Referenced by Element(), EndSequence(), EndVector(), Field(), StartSequence(), and StartVector().

◆ in

std::string flatbuffers::ToStringVisitor::in

Definition at line 300 of file minireflect.h.

Referenced by append_indent().

◆ indent_level

size_t flatbuffers::ToStringVisitor::indent_level

Definition at line 301 of file minireflect.h.

Referenced by append_indent(), EndSequence(), EndVector(), StartSequence(), and StartVector().

◆ q

bool flatbuffers::ToStringVisitor::q

Definition at line 299 of file minireflect.h.

Referenced by Field(), and Named().

◆ s

◆ vector_delimited

bool flatbuffers::ToStringVisitor::vector_delimited

Definition at line 302 of file minireflect.h.

Referenced by Element(), EndVector(), and StartVector().


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