Vowpal Wabbit
Public Member Functions | Private Attributes | List of all members
ArrayState< audit > Class Template Reference

#include <parse_example_json.h>

Inheritance diagram for ArrayState< audit >:
BaseState< audit >

Public Member Functions

 ArrayState ()
 
BaseState< audit > * StartArray (Context< audit > &ctx) override
 
BaseState< audit > * Float (Context< audit > &ctx, float f) override
 
BaseState< audit > * Uint (Context< audit > &ctx, unsigned f) override
 
BaseState< audit > * Null (Context< audit > &) override
 
BaseState< audit > * StartObject (Context< audit > &ctx) override
 
BaseState< audit > * EndArray (Context< audit > &ctx, rapidjson::SizeType) override
 
- Public Member Functions inherited from BaseState< audit >
 BaseState (const char *pname)
 
virtual BaseState< audit > * Bool (Context< audit > &ctx, bool b)
 
virtual BaseState< audit > * String (Context< audit > &ctx, const char *str, rapidjson::SizeType len, bool)
 
virtual BaseState< audit > * Key (Context< audit > &ctx, const char *str, rapidjson::SizeType len, bool)
 
virtual BaseState< audit > * EndObject (Context< audit > &ctx, rapidjson::SizeType)
 

Private Attributes

feature_index array_hash
 

Additional Inherited Members

- Public Attributes inherited from BaseState< audit >
const char * name
 

Detailed Description

template<bool audit>
class ArrayState< audit >

Definition at line 536 of file parse_example_json.h.

Constructor & Destructor Documentation

◆ ArrayState()

template<bool audit>
ArrayState< audit >::ArrayState ( )
inline

Definition at line 541 of file parse_example_json.h.

541 : BaseState<audit>("Array") {}

Member Function Documentation

◆ EndArray()

template<bool audit>
BaseState<audit>* ArrayState< audit >::EndArray ( Context< audit > &  ctx,
rapidjson::SizeType   
)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 590 of file parse_example_json.h.

References Context< audit >::PopNamespace().

591  {
592  return ctx.PopNamespace();
593  }
BaseState< audit > * PopNamespace()

◆ Float()

template<bool audit>
BaseState<audit>* ArrayState< audit >::Float ( Context< audit > &  ctx,
float  f 
)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 558 of file parse_example_json.h.

References Context< audit >::CurrentNamespace().

559  {
560  if (audit)
561  {
562  std::stringstream str;
563  str << '[' << (array_hash - ctx.CurrentNamespace().namespace_hash) << ']';
564 
565  ctx.CurrentNamespace().AddFeature(f, array_hash, str.str().c_str());
566  }
567  else
568  ctx.CurrentNamespace().AddFeature(f, array_hash, nullptr);
569  array_hash++;
570 
571  return this;
572  }
Namespace< audit > & CurrentNamespace()
feature_index array_hash
float f
Definition: cache.cc:40

◆ Null()

template<bool audit>
BaseState<audit>* ArrayState< audit >::Null ( Context< audit > &  )
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 576 of file parse_example_json.h.

577  {
578  // ignore null values and stay in current state
579  return this;
580  }

◆ StartArray()

template<bool audit>
BaseState<audit>* ArrayState< audit >::StartArray ( Context< audit > &  ctx)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 543 of file parse_example_json.h.

References Context< audit >::CurrentNamespace(), Context< audit >::error(), Context< audit >::key, Context< audit >::previous_state, and Context< audit >::PushNamespace().

544  {
545  if (ctx.previous_state == this)
546  {
547  ctx.error() << "Nested arrays are not supported";
548  return nullptr;
549  }
550 
551  ctx.PushNamespace(ctx.key, ctx.previous_state);
552 
553  array_hash = ctx.CurrentNamespace().namespace_hash;
554 
555  return this;
556  }
const char * key
std::stringstream & error()
Namespace< audit > & CurrentNamespace()
feature_index array_hash
BaseState< audit > * previous_state
void PushNamespace(const char *ns, BaseState< audit > *return_state)

◆ StartObject()

template<bool audit>
BaseState<audit>* ArrayState< audit >::StartObject ( Context< audit > &  ctx)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 582 of file parse_example_json.h.

References Context< audit >::CurrentNamespace(), Context< audit >::default_state, Context< audit >::namespace_path, and Context< audit >::PushNamespace().

583  {
584  // parse properties
585  ctx.PushNamespace(ctx.namespace_path.size() > 0 ? ctx.CurrentNamespace().name : " ", this);
586 
587  return &ctx.default_state;
588  }
std::vector< Namespace< audit > > namespace_path
Namespace< audit > & CurrentNamespace()
DefaultState< audit > default_state
void PushNamespace(const char *ns, BaseState< audit > *return_state)

◆ Uint()

template<bool audit>
BaseState<audit>* ArrayState< audit >::Uint ( Context< audit > &  ctx,
unsigned  f 
)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 574 of file parse_example_json.h.

574 { return Float(ctx, (float)f); }
BaseState< audit > * Float(Context< audit > &ctx, float f) override
float f
Definition: cache.cc:40

Member Data Documentation

◆ array_hash

template<bool audit>
feature_index ArrayState< audit >::array_hash
private

Definition at line 538 of file parse_example_json.h.


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