19 #ifndef avro_Validating_hh__ 20 #define avro_Validating_hh__ 22 #include <boost/noncopyable.hpp> 28 #include "ValidSchema.hh" 39 void setCount(int64_t val) {}
41 bool typeIsExpected(
Type type)
const {
45 Type nextTypeExpected()
const {
49 int nextSizeExpected()
const {
53 bool getCurrentRecordName(std::string &name)
const {
57 bool getNextFieldName(std::string &name)
const {
61 void checkTypeExpected(
Type type) { }
62 void checkFixedSizeExpected(
int size) { }
73 class AVRO_DECL
Validator :
private boost::noncopyable
79 void setCount(int64_t val);
81 bool typeIsExpected(
Type type)
const {
82 return (expectedTypesFlag_ & typeToFlag(type)) != 0;
85 Type nextTypeExpected()
const {
89 int nextSizeExpected()
const;
91 bool getCurrentRecordName(std::string &name)
const;
92 bool getNextFieldName(std::string &name)
const;
94 void checkTypeExpected(
Type type) {
95 if(! typeIsExpected(type)) {
97 boost::format(
"Type %1% does not match schema %2%")
104 void checkFixedSizeExpected(
int size) {
105 if( nextSizeExpected() != size) {
107 boost::format(
"Wrong size for fixed, got %1%, expected %2%")
108 % size % nextSizeExpected()
116 typedef uint32_t flag_t;
118 flag_t typeToFlag(
Type type)
const {
119 flag_t flag = (1L << type);
123 void setupOperation(
const NodePtr &node);
125 void setWaitingForCount();
131 bool countingSetup();
132 void countingAdvance();
136 void setupFlag(
Type type);
141 flag_t expectedTypesFlag_;
142 bool compoundStarted_;
143 bool waitingForCount_;
146 struct CompoundType {
147 explicit CompoundType(
const NodePtr &n) :
154 std::vector<CompoundType> compoundStack_;
155 std::vector<size_t> counters_;
Type
The "type" for the schema.
Definition: Types.hh:31
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
This class is used by both the ValidatingSerializer and ValidationParser objects. ...
Definition: Validator.hh:73
Wrapper for std::runtime_error that provides convenience constructor for boost::format objects...
Definition: Exception.hh:31
A ValidSchema is basically a non-mutable Schema that has passed some minumum of sanity checks...
Definition: ValidSchema.hh:40
Definition: Validator.hh:32