|
@@ -9,7 +9,7 @@ namespace isc { namespace data {
|
|
|
|
|
|
///
|
|
|
/// A standard DataDefinition exception that is thrown when a
|
|
|
- /// .spec file could not be parsed.
|
|
|
+ /// specification is not in the correct form.
|
|
|
///
|
|
|
/// TODO: use jinmei's exception class as a base and not c_str in
|
|
|
/// what() there
|
|
@@ -29,6 +29,9 @@ namespace isc { namespace data {
|
|
|
/// This class holds that specification, and provides a function to
|
|
|
/// validate a set of data, to see whether it conforms to the given
|
|
|
/// specification
|
|
|
+ ///
|
|
|
+ /// The form of the specification is described in doc/ (TODO)
|
|
|
+ ///
|
|
|
class DataDefinition {
|
|
|
public:
|
|
|
explicit DataDefinition() {};
|
|
@@ -37,12 +40,26 @@ namespace isc { namespace data {
|
|
|
/// \param e The Element containing the data specification
|
|
|
explicit DataDefinition(ElementPtr e) : definition(e) {};
|
|
|
// todo: make check default false, or leave out option completely and always check?
|
|
|
+ /// Creates a \c DataDefinition instance from the given .spec
|
|
|
+ /// file stream. If check is true, and the definition is not of
|
|
|
+ /// the correct form, a DataDefinitionError is thrown. If the
|
|
|
+ /// file could not be parsed, a ParseError is thrown.
|
|
|
+ /// \param in The std::istream containing the .spec file data
|
|
|
+ /// \param check If true, the data definition is checked to be
|
|
|
+ /// of the correct form
|
|
|
explicit DataDefinition(std::istream& in, const bool check = true)
|
|
|
throw(ParseError, DataDefinitionError);
|
|
|
|
|
|
+ /// Returns the base \c element of the data definition contained
|
|
|
+ /// by this instance
|
|
|
+ /// \return ElementPtr Shared pointer to the data definition
|
|
|
const ElementPtr getDefinition() { return definition; };
|
|
|
// returns true if the given element conforms to this data
|
|
|
// definition scheme
|
|
|
+ /// Validates the given data for this specification.
|
|
|
+ /// \param data The base \c Element of the data to check
|
|
|
+ /// \return true if the data conforms to the specification,
|
|
|
+ /// false otherwise.
|
|
|
bool validate(const ElementPtr data);
|
|
|
|
|
|
private:
|