const int JSONFeed::FEED_FAILED_EVT;
JSONFeed::JSONFeed()
- : StateModel(), buffer_(), error_message_(), open_scopes_(0),
- output_() {
+ : StateModel(), error_message_(), open_scopes_(0), output_() {
}
void
if (getNextEvent() == NEED_MORE_DATA_EVT) {
transition(getCurrState(), MORE_DATA_PROVIDED_EVT);
}
- buffer_.insert(buffer_.end(), static_cast<const char*>(buf),
+ buffer_.assign(static_cast<const char*>(buf),
static_cast<const char*>(buf) + buf_size);
+ data_ptr_ = 0;
}
}
bool
JSONFeed::popNextFromBuffer(char& next) {
// If there are any characters in the buffer, pop next.
- if (!buffer_.empty()) {
- next = buffer_.front();
- buffer_.pop_front();
+ if (!buffer_.empty() && (data_ptr_ < buffer_.size())) {
+ next = buffer_[data_ptr_++];
return (true);
}
return (false);
transition(JSON_END_ST, FEED_OK_EVT);
} else {
- transition(getCurrState(), DATA_READ_OK_EVT);
+ postNextEvent(DATA_READ_OK_EVT);
}
break;
break;
default:
- transition(getCurrState(), DATA_READ_OK_EVT);
+ postNextEvent(DATA_READ_OK_EVT);
}
}
}
#include <exceptions/exceptions.h>
#include <util/state_model.h>
#include <boost/shared_ptr.hpp>
-#include <list>
#include <stdint.h>
#include <string>
+#include <vector>
namespace isc {
namespace config {
//@}
/// @brief Internal buffer from which the feed reads data.
- std::list<char> buffer_;
+ std::vector<char> buffer_;
+
+ /// @brief Holds pointer to the next byte in the buffer to be read.
+ size_t data_ptr_;
/// @brief Error message set by @ref onModelFailure.
std::string error_message_;