13 #include <boost/shared_ptr.hpp> 79 static const int RECEIVE_START_ST = SM_DERIVED_STATE_MIN + 1;
82 static const int WHITESPACE_BEFORE_JSON_ST = SM_DERIVED_STATE_MIN + 2;
85 static const int EOL_COMMENT_BEFORE_JSON_ST = SM_DERIVED_STATE_MIN + 3;
88 static const int START_COMMENT_BEFORE_JSON_ST = SM_DERIVED_STATE_MIN + 4;
91 static const int C_COMMENT_BEFORE_JSON_ST = SM_DERIVED_STATE_MIN + 5;
94 static const int STOP_COMMENT_BEFORE_JSON_ST = SM_DERIVED_STATE_MIN + 6;
97 static const int JSON_START_ST = SM_DERIVED_STATE_MIN + 7;
100 static const int INNER_JSON_ST = SM_DERIVED_STATE_MIN + 8;
103 static const int STRING_JSON_ST = SM_DERIVED_STATE_MIN + 9;
106 static const int ESCAPE_JSON_ST = SM_DERIVED_STATE_MIN + 10;
109 static const int EOL_COMMENT_ST = SM_DERIVED_STATE_MIN + 11;
112 static const int START_COMMENT_ST = SM_DERIVED_STATE_MIN + 12;
115 static const int C_COMMENT_ST = SM_DERIVED_STATE_MIN + 13;
118 static const int STOP_COMMENT_ST = SM_DERIVED_STATE_MIN + 14;
121 static const int JSON_END_ST = SM_DERIVED_STATE_MIN + 15;
128 static const int FEED_OK_ST = SM_DERIVED_STATE_MIN + 100;
133 static const int FEED_FAILED_ST = SM_DERIVED_STATE_MIN + 101;
143 static const int DATA_READ_OK_EVT = SM_DERIVED_EVENT_MIN + 1;
146 static const int NEED_MORE_DATA_EVT = SM_DERIVED_EVENT_MIN + 2;
149 static const int MORE_DATA_PROVIDED_EVT = SM_DERIVED_EVENT_MIN + 3;
152 static const int FEED_OK_EVT = SM_DERIVED_EVENT_MIN + 100;
155 static const int FEED_FAILED_EVT = SM_DERIVED_EVENT_MIN + 101;
184 bool needData()
const;
191 return (error_message_);
212 void postBuffer(
const void* buf,
const size_t buf_size);
219 using StateModel::runModel;
222 virtual void defineEvents();
225 virtual void verifyEvents();
228 virtual void defineStates();
236 void feedFailure(
const std::string& error_msg);
241 virtual void onModelFailure(
const std::string& explanation);
257 char getNextFromBuffer();
272 void invalidEventError(
const std::string& handler_name,
273 const unsigned int event);
281 bool popNextFromBuffer(
char& next);
288 void receiveStartHandler();
291 void whiteSpaceBeforeJSONHandler();
294 void eolCommentBeforeJSONHandler();
297 void startCommentBeforeJSONHandler();
300 void cCommentBeforeJSONHandler();
303 void stopCommentBeforeJSONHandler();
306 void innerJSONHandler();
309 void stringJSONHandler();
312 void escapeJSONHandler();
315 void eolCommentHandler();
318 void startCommentHandler();
321 void cCommentHandler();
324 void stopCommentHandler();
327 void endJSONHandler();
332 std::vector<char> buffer_;
338 std::string error_message_;
342 uint64_t open_scopes_;
351 #endif // JSON_FEED_H JSONFeedError(const char *file, size_t line, const char *what)
Implements a finite state machine.
boost::shared_ptr< Element > ElementPtr
A generic exception thrown upon an error in the JSONFeed.
boost::shared_ptr< JSONFeed > JSONFeedPtr
Pointer to the JSONFeed.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
State model for asynchronous read of data in JSON format.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
boost::shared_ptr< const JSONFeed > ConstJSONFeedPtr
Pointer to the const JSONFeed.
std::string getProcessedText() const
Returns the text parsed into the buffer.
This file defines the class StateModel.
std::string getErrorMessage() const
Returns error string when data processing has failed.