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 359 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 367 of file minireflect.h.

368 : d(delimiter), q(quotes), in(indent), indent_level(0), vector_delimited(vdelimited)
369 {
370 }

◆ ToStringVisitor() [2/2]

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

Definition at line 371 of file minireflect.h.

372 : d(delimiter), q(false), in(""), indent_level(0), vector_delimited(true)
373 {
374 }

Member Function Documentation

◆ append_indent()

void flatbuffers::ToStringVisitor::append_indent ( )
inline

Definition at line 376 of file minireflect.h.

377 {
378 for (size_t i = 0; i < indent_level; i++)
379 {
380 s += in;
381 }
382 }

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 434 of file minireflect.h.

434{ 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 435 of file minireflect.h.

435{ 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 444 of file minireflect.h.

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

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 478 of file minireflect.h.

480 {
481 if (i)
482 {
483 s += ",";
485 {
486 s += d;
488 }
489 else
490 {
491 s += " ";
492 }
493 }
494 }

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

◆ EndSequence()

void flatbuffers::ToStringVisitor::EndSequence ( )
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 390 of file minireflect.h.

391 {
392 s += d;
393 indent_level--;
395 s += "}";
396 }

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

◆ EndVector()

void flatbuffers::ToStringVisitor::EndVector ( )
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 464 of file minireflect.h.

465 {
467 {
468 s += d;
469 indent_level--;
471 }
472 else
473 {
474 s += " ";
475 }
476 s += "]";
477 }

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 397 of file minireflect.h.

399 {
400 if (!val)
401 return;
402 if (set_idx)
403 {
404 s += ",";
405 s += d;
406 }
408 if (name)
409 {
410 if (q)
411 s += "\"";
412 s += name;
413 if (q)
414 s += "\"";
415 s += ": ";
416 }
417 }

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

◆ Float()

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

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 443 of file minireflect.h.

443{ 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 439 of file minireflect.h.

439{ Named(x, name); }

References Named().

◆ Long()

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

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 441 of file minireflect.h.

441{ s += NumToString(x); }

References flatbuffers::NumToString(), and s.

◆ Named()

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

Definition at line 418 of file minireflect.h.

419 {
420 if (name)
421 {
422 if (q)
423 s += "\"";
424 s += name;
425 if (q)
426 s += "\"";
427 }
428 else
429 {
430 s += NumToString(x);
431 }
432 }

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 437 of file minireflect.h.

437{ Named(x, name); }

References Named().

◆ StartSequence()

void flatbuffers::ToStringVisitor::StartSequence ( )
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 384 of file minireflect.h.

385 {
386 s += "{";
387 s += d;
388 indent_level++;
389 }

References d, indent_level, and s.

◆ StartVector()

void flatbuffers::ToStringVisitor::StartVector ( )
inlinevirtual

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 450 of file minireflect.h.

451 {
452 s += "[";
454 {
455 s += d;
456 indent_level++;
458 }
459 else
460 {
461 s += " ";
462 }
463 }

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

◆ String()

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

Definition at line 445 of file minireflect.h.

446 {
447 EscapeString(str->c_str(), str->size(), &s, true, false);
448 }
bool EscapeString(const char *s, size_t length, std::string *_text, bool allow_non_utf8, bool natural_utf8)
Definition util.h:652
const char * str
Definition util.h:290

References flatbuffers::EscapeString(), s, and flatbuffers::str.

◆ UChar()

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

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 436 of file minireflect.h.

436{ Named(x, name); }

References Named().

◆ UInt()

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

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 440 of file minireflect.h.

440{ Named(x, name); }

References Named().

◆ ULong()

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

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 442 of file minireflect.h.

442{ s += NumToString(x); }

References flatbuffers::NumToString(), and s.

◆ Unknown()

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

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 449 of file minireflect.h.

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

References s.

◆ UShort()

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

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 438 of file minireflect.h.

438{ Named(x, name); }

References Named().

◆ UType()

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

Reimplemented from flatbuffers::IterationVisitor.

Definition at line 433 of file minireflect.h.

433{ Named(x, name); }

References Named().

Field Documentation

◆ d

std::string flatbuffers::ToStringVisitor::d

Definition at line 362 of file minireflect.h.

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

◆ in

std::string flatbuffers::ToStringVisitor::in

Definition at line 364 of file minireflect.h.

Referenced by append_indent().

◆ indent_level

size_t flatbuffers::ToStringVisitor::indent_level

Definition at line 365 of file minireflect.h.

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

◆ q

bool flatbuffers::ToStringVisitor::q

Definition at line 363 of file minireflect.h.

Referenced by Field(), and Named().

◆ s

◆ vector_delimited

bool flatbuffers::ToStringVisitor::vector_delimited

Definition at line 366 of file minireflect.h.

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


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