Definition at line 718 of file JSON.hh.
◆ StreamReader() [1/2]
| marley::StreamReader::StreamReader |
( |
std::istream & | stream, |
|
|
std::string | filename = {}, |
|
|
StreamReader * | parent = nullptr ) |
|
inline |
Definition at line 720 of file JSON.hh.
720 {},
721 StreamReader* parent = nullptr)
722 : stream_(&stream), filename_(std::move(filename)),
723 parent_(parent) {}
◆ StreamReader() [2/2]
| marley::StreamReader::StreamReader |
( |
std::unique_ptr< std::istream > | stream, |
|
|
std::string | filename = {}, |
|
|
StreamReader * | parent = nullptr ) |
|
inline |
Definition at line 725 of file JSON.hh.
726 {}, StreamReader* parent = nullptr)
727 : stream_(stream.get()), owner_(std::move(stream)),
728 filename_(std::move(filename)), parent_(parent) {}
◆ col()
| size_t marley::StreamReader::col |
( |
| ) |
const |
|
inline |
◆ filename()
| const std::string & marley::StreamReader::filename |
( |
| ) |
const |
|
inline |
◆ format_error()
| std::string marley::StreamReader::format_error |
( |
const std::string & | message | ) |
const |
|
inline |
Definition at line 775 of file JSON.hh.
775 {
776 std::string result;
777 auto report_col = [&](const StreamReader& r) -> std::string {
778 return std::to_string(r.prev_known_ ? r.prev_line_ : r.line_)
779 + ", column " + std::to_string(r.prev_known_ ? r.prev_col_ : r.col_);
780 };
781 if (!filename_.empty()) {
782 result += "In \"" + filename_ + "\", line " + report_col(*this)
783 + ":\n";
784 }
785 std::string indent = " ";
786 for (const StreamReader* p = parent_; p; p = p->parent_) {
787 result += indent + "(included from \"" + p->filename_
788 + "\", line " + report_col(*p) + ")\n";
789 indent += " ";
790 }
791 result += message;
792 return result;
793 }
◆ get()
| char marley::StreamReader::get |
( |
| ) |
|
|
inline |
Definition at line 730 of file JSON.hh.
730 {
731 if (has_putback_) {
732 has_putback_ = false;
733 char c = putback_char_;
734 if (c == '\n') { ++line_; col_ = 1; }
735 else { ++col_; }
736 return c;
737 }
738 char c;
739 if (stream_->get(c)) {
740 prev_line_ = line_; prev_col_ = col_; prev_known_ = true;
741 if (c == '\n') { ++line_; col_ = 1; }
742 else { ++col_; }
743 return c;
744 }
745 fail_ = true;
746 return '\0';
747 }
◆ good()
| bool marley::StreamReader::good |
( |
| ) |
const |
|
inline |
Definition at line 766 of file JSON.hh.
766 {
767 if (has_putback_) return true;
768 return !fail_ && stream_->good();
769 }
◆ line()
| size_t marley::StreamReader::line |
( |
| ) |
const |
|
inline |
◆ peek()
| char marley::StreamReader::peek |
( |
| ) |
|
|
inline |
Definition at line 749 of file JSON.hh.
749 {
750 if (has_putback_) return putback_char_;
751 int ch = stream_->peek();
752 if (ch == std::char_traits<char>::eof()) {
753 fail_ = true; return '\0';
754 }
755 return static_cast<char>(ch);
756 }
◆ unget()
| void marley::StreamReader::unget |
( |
char | c | ) |
|
|
inline |
Definition at line 758 of file JSON.hh.
758 {
759 if (prev_known_) {
760 line_ = prev_line_; col_ = prev_col_;
761 }
762 putback_char_ = c;
763 has_putback_ = true;
764 }
The documentation for this class was generated from the following file:
- /home/sjg/Desktop/marley/include/marley/JSON.hh