Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_