Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
SchemaErrorLogger.h
1/*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 * SchemaErrorLogger.h
17 * Captures errors while parsing the schema.
18 * Copyright (C) 2014 Simon Newton
19 */
20
21#ifndef COMMON_WEB_SCHEMAERRORLOGGER_H_
22#define COMMON_WEB_SCHEMAERRORLOGGER_H_
23
24#include <ola/base/Macro.h>
25
26#include <ostream>
27#include <string>
28
29#include "ola/web/JsonPointer.h"
30
31namespace ola {
32namespace web {
33
42 public:
47 explicit SchemaErrorLogger(JsonPointer *pointer) : m_pointer(pointer) {}
48
52 bool HasError() const;
53
58 std::string ErrorString() const;
59
63 std::ostream& Error();
64
68 void Reset();
69
70 private:
71 std::ostringstream m_first_error;
72 std::ostringstream m_extra_errors;
73 JsonPointer *m_pointer;
74
75 SchemaErrorLogger(const SchemaErrorLogger &) = delete;
76 const SchemaErrorLogger &operator=(const SchemaErrorLogger &) = delete;
77};
78} // namespace web
79} // namespace ola
80#endif // COMMON_WEB_SCHEMAERRORLOGGER_H_
An implementation of Json Pointers (RFC 6901).
Helper macros.
A JSON pointer (RFC 6901) refers to a possible element in a JSON data structure.
Definition JsonPointer.h:66
The SchemaErrorLogger captures errors while parsing the schema.
Definition SchemaErrorLogger.h:41
std::string ErrorString() const
Return the first error.
Definition SchemaErrorLogger.cpp:33
std::ostream & Error()
Log an error.
Definition SchemaErrorLogger.cpp:37
bool HasError() const
Check if there was an error logged.
Definition SchemaErrorLogger.cpp:29
SchemaErrorLogger(JsonPointer *pointer)
Create a new SchemaErrorLogger.
Definition SchemaErrorLogger.h:47
void Reset()
Clear the saved errors.
Definition SchemaErrorLogger.cpp:46
The namespace containing all OLA symbols.
Definition Credentials.cpp:44