Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
31 namespace ola {
32 namespace 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  DISALLOW_COPY_AND_ASSIGN(SchemaErrorLogger);
76 };
77 } // namespace web
78 } // namespace ola
79 #endif // COMMON_WEB_SCHEMAERRORLOGGER_H_
std::ostream & Error()
Log an error.
Definition: SchemaErrorLogger.cpp:37
void Reset()
Clear the saved errors.
Definition: SchemaErrorLogger.cpp:46
std::string ErrorString() const
Return the first error.
Definition: SchemaErrorLogger.cpp:33
A JSON pointer (RFC 6901) refers to a possible element in a JSON data structure.
Definition: JsonPointer.h:66
Helper macros.
bool HasError() const
Check if there was an error logged.
Definition: SchemaErrorLogger.cpp:29
An implementation of Json Pointers (RFC 6901).
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
SchemaErrorLogger(JsonPointer *pointer)
Create a new SchemaErrorLogger.
Definition: SchemaErrorLogger.h:47
The SchemaErrorLogger captures errors while parsing the schema.
Definition: SchemaErrorLogger.h:41