13 #include <boost/shared_ptr.hpp> 164 return (error_message_);
185 void postBuffer(
const void* buf,
const size_t buf_size);
192 using StateModel::runModel;
195 virtual void defineEvents();
198 virtual void verifyEvents();
201 virtual void defineStates();
209 void feedFailure(
const std::string& error_msg);
214 virtual void onModelFailure(
const std::string& explanation);
230 char getNextFromBuffer();
245 void invalidEventError(
const std::string& handler_name,
246 const unsigned int event);
254 bool popNextFromBuffer(
char& next);
261 void receiveStartHandler();
264 void whiteSpaceBeforeJSONHandler();
267 void innerJSONHandler();
270 void stringJSONHandler();
273 void escapeJSONHandler();
276 void endJSONHandler();
281 std::vector<char> buffer_;
287 std::string error_message_;
291 uint64_t open_scopes_;
300 #endif // JSON_FEED_H static const int DATA_READ_OK_EVT
Chunk of data successfully read and parsed.
JSONFeedError(const char *file, size_t line, const char *what)
void postBuffer(const void *buf, const size_t buf_size)
Receives additional data read from a data stream.
Implements a finite state machine.
static const int FEED_FAILED_EVT
Invalid syntax detected.
static const int WHITESPACE_BEFORE_JSON_ST
Skipping whitespaces before actual JSON.
static const int FEED_OK_ST
Found opening and closing brace or square bracket.
static const int RECEIVE_START_ST
State indicating a beginning of a feed.
bool needData() const
Checks if the model needs additional data to continue.
boost::shared_ptr< Element > ElementPtr
static const int MORE_DATA_PROVIDED_EVT
New data provided and parsing should continue.
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.
static const int STRING_JSON_ST
Parsing JSON string.
static const int INNER_JSON_ST
Parsing JSON.
static const int NEED_MORE_DATA_EVT
Unable to proceed with parsing until new data is provided.
static const int ESCAPE_JSON_ST
JSON escape next character.
static const int FEED_OK_EVT
Found opening brace and the matching closing brace.
static const int SM_DERIVED_EVENT_MIN
Value at which custom events in a derived class should begin.
static const int SM_DERIVED_STATE_MIN
Value at which custom states in a derived class should begin.
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-dhcp-ddns.
boost::shared_ptr< const JSONFeed > ConstJSONFeedPtr
Pointer to the const JSONFeed.
std::string getProcessedText() const
Returns the text parsed into the buffer.
static const int JSON_END_ST
Found last closing brace or square bracket.
data::ElementPtr toElement() const
Returns processed data as a structure of isc::data::Element objects.
bool feedOk() const
Checks if the data have been successfully processed.
This file defines the class StateModel.
std::string getErrorMessage() const
Returns error string when data processing has failed.
static const int JSON_START_ST
Found first opening brace or square bracket.
void poll()
Runs the model as long as data is available.
void initModel()
Initializes state model.
static const int FEED_FAILED_ST
Invalid syntax detected.