1 /************************************************************************
3 ** Copyright (C) 2010 Strahinja Markovic
5 ** This file is part of FlightCrew.
7 ** FlightCrew is free software: you can redistribute it and/or modify
8 ** it under the terms of the GNU Lesser General Public License as published
9 ** by the Free Software Foundation, either version 3 of the License, or
10 ** (at your option) any later version.
12 ** FlightCrew is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU Lesser General Public License for more details.
17 ** You should have received a copy of the GNU Lesser General Public License
18 ** along with FlightCrew. If not, see <http://www.gnu.org/licenses/>.
20 *************************************************************************/
28 #include <NodeLocationInfo.h>
30 #include "DllExporting.h"
33 // This warning complains that the private members
34 // of this class that use the STL are not being exported
35 // for use by clients.
36 // Since the clients can't even access the private members
37 // of this class, it's not a problem.
38 # pragma warning( disable : 4251 )
45 * Defines a validation result, usually a warning or error.
46 * Users that just want to consume a prepared Result should
47 * look at the GetErrorLine, GetErrorColumn and GetMessage
50 class FC_WIN_DLL_API Result
58 * @param result_id The ID of the Result.
59 * @param node_location The DOM node location where the result was found.
61 Result( ResultId result_id = ALL_OK,
62 XercesExt::NodeLocationInfo node_location = XercesExt::NodeLocationInfo() );
65 * Returns the type of the Result, either a warning or an error.
67 * @return The type of the Result.
69 ResultType GetResultType() const;
72 * Returns the ID of the Result.
76 ResultId GetResultId() const;
79 * Sets the Result's ID.
81 * @param result_id The new ID.
82 * @return A reference to this result, for easy function chaining.
84 Result& SetResultId( ResultId result_id );
87 * Returns the error line number.
89 * @return The line number.
91 int GetErrorLine() const;
94 * Sets the Result's error line number.
96 * @param result_id The new line number.
97 * @return A reference to this result, for easy function chaining.
99 Result& SetErrorLine( int error_line );
102 * Returns the error column number.
104 * @return The column number.
106 int GetErrorColumn() const;
109 * Sets the Result's error column number.
110 * @note This is usually unreliable information because of the way
111 * Xerces works with XSD's. It's going to be in the ballpark, but
112 * it won't (usually) have the precision you want.
114 * @param result_id The new column number.
115 * @return A reference to this result, for easy function chaining.
117 Result& SetErrorColumn( int error_column );
120 * Returns the path to the file in which this Result occurs.
121 * The path is relative to the root of the epub document.
123 * @return The path in UTF-8.
125 std::string GetFilepath() const;
128 * Sets the path to the file in which this Result occurs.
129 * The path should be relative to the root of the epub document.
131 * @param filepath The new path in UTF-8.
132 * @return A reference to this result, for easy function chaining.
134 Result& SetFilepath( const std::string &filepath );
137 * Adds a message argument that fills in a placeholder in the
138 * message that applies to this Result's ID. The order in which
139 * the arguments are added is the order in which they will replace
142 * @param message_argument The argument in UTF-8.
143 * @return A reference to this result, for easy function chaining.
145 Result& AddMessageArgument( const std::string &message_argument );
148 * Sets all the message arguments that will fill in the placeholders
149 * in the message that applies to this Result's ID. The order in which
150 * the arguments are added is the order in which they will replace
153 * @param message_arguments The arguments in UTF-8.
154 * @return A reference to this result, for easy function chaining.
156 Result& SetMessageArguments( const std::vector< std::string > &message_arguments );
159 * Returns all the stored message arguments.
161 * @return The current message arguments.
163 const std::vector< std::string > &GetMessageArguments() const;
166 * Returns the error message for this Result with all the
167 * message arguments already applied.
169 std::string GetMessage() const;
172 * Sets a custom message for this Result. This overrides the template
173 * message for Results with this ID and ignores all stored message arguments.
175 Result& SetCustomMessage( const std::string &custom_message );
177 bool operator< ( const Result& other ) const;
179 bool operator== ( const Result& other ) const;
183 ///////////////////////////////
184 // PRIVATE MEMBER VARIABLES
185 ///////////////////////////////
193 * The line where this Result was found in the content document.
198 * The column in the line where this Result was found in the content document.
203 * The message arguments for the placeholders in the message template.
205 std::vector< std::string > m_MessageArguments;
208 * A custom message that overrides the template one.
210 std::string m_CustomMessage;
213 * The relative path to the file where the Result was found.
215 std::string m_Filepath;
218 } // namespace FlightCrew