All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
ParseHext.h
Go to the documentation of this file.
1 // Copyright 2015 Thomas Trapp
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef HEXT_PARSE_HEXT_H_INCLUDED
16 #define HEXT_PARSE_HEXT_H_INCLUDED
17 
18 /// @file
19 /// Declares hext::ParseHext
20 
21 #include <cstddef>
22 
23 #include "hext/Rule.h"
24 #include "hext/SyntaxError.h"
25 
26 
27 namespace hext {
28 
29 
30 /// Parses a null-terminated string containing hext rule definitions.
31 /// Throws SyntaxError with a detailed error message on invalid input.
32 ///
33 /// @par Example:
34 /// ~~~~~~~~~~~~~
35 /// try {
36 /// Rule rule = ParseHext("<a href:link />");
37 /// } catch( SyntaxError& e ) {
38 /// // e.what() will contain a detailed error message.
39 /// }
40 /// ~~~~~~~~~~~~~
41 ///
42 /// @throws SyntaxError
43 ///
44 /// @param hext: A null-terminated string containing hext rule definitions.
45 /// @returns The parsed Rule.
46 Rule ParseHext(const char * hext);
47 
48 /// Parses a buffer containing hext rule definitions.
49 /// Throws SyntaxError with a detailed error message on invalid input.
50 ///
51 /// @par Example:
52 /// ~~~~~~~~~~~~~
53 /// std::string hext_str("<a href:link />");
54 /// try {
55 /// Rule rule = ParseHext(hext_str.c_str(), hext_str.size());
56 /// // ... do sth. with rule ...
57 /// } catch( SyntaxError& e ) {
58 /// // e.what() will contain a detailed error message.
59 /// }
60 /// ~~~~~~~~~~~~~
61 ///
62 /// @throws SyntaxError
63 ///
64 /// @param hext: A string containing hext rule definitions.
65 /// @param size: The length of the string.
66 /// @returns The parsed Rule.
67 Rule ParseHext(const char * hext, std::size_t size);
68 
69 
70 } // namespace hext
71 
72 
73 #endif // HEXT_PARSE_HEXT_H_INCLUDED
74 
Declares hext::SyntaxError.
Declares hext::Rule.
Rule ParseHext(const char *hext)
Parses a null-terminated string containing hext rule definitions.