Skip to content

Commit

Permalink
Super-rudimentary documentation...
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Mar 18, 2018
1 parent 9201904 commit 8f8f00f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/serialization/tag.hpp
Expand Up @@ -34,6 +34,10 @@ class config;
namespace schema_validation
{

/**
* Stores information about a schema type.
* This is an abstract base class for several variants of schema type.
*/
class class_type {
protected:
std::string name_;
Expand All @@ -45,13 +49,21 @@ class class_type {
static std::shared_ptr<class_type> from_config(const config& cfg);
};

/**
* Stores information about a schema type.
* This type represents a simple pattern match.
*/
class class_type_simple : public class_type {
boost::regex pattern_;
public:
class_type_simple(const std::string& name, const std::string& pattern) : class_type(name), pattern_(pattern) {}
bool matches(const std::string& value, const map& type_map) const override;
};

/**
* Stores information about a schema type.
* This type represents a name alias for another type.
*/
class class_type_alias : public class_type {
mutable std::shared_ptr<class_type> cached_;
std::string link_;
Expand All @@ -60,6 +72,10 @@ class class_type_alias : public class_type {
bool matches(const std::string& value, const map& type_map) const override;
};

/**
* Stores information about a schema type.
* This is an abstract base class for composite types.
*/
class class_type_composite : public class_type {
protected:
std::vector<std::shared_ptr<class_type>> subtypes_;
Expand All @@ -71,18 +87,30 @@ class class_type_composite : public class_type {
}
};

/**
* Stores information about a schema type.
* Represents a union type, which matches if any of its subtypes match.
*/
class class_type_union : public class_type_composite {
public:
class_type_union(const std::string& name) : class_type_composite(name) {}
bool matches(const std::string& value, const map& type_map) const override;
};

/**
* Stores information about a schema type.
* Represents an intersection type, which matches if all of its subtypes match.
*/
class class_type_intersection : public class_type_composite {
public:
class_type_intersection(const std::string& name) : class_type_composite(name) {}
bool matches(const std::string& value, const map& type_map) const override;
};

/**
* Stores information about a schema type.
* Represents a list type, where each list element is itself a union.
*/
class class_type_list : public class_type_union {
boost::regex split_;
int min_ = 0, max_ = -1;
Expand Down

0 comments on commit 8f8f00f

Please sign in to comment.