00001 #ifndef SDXVALIDATOR_H
00002 #define SDXVALIDATOR_H
00003
00004
00005 #include <map>
00006 #include <set>
00007 #include <string>
00008 #include <vector>
00009
00010 #include "SDXContentHandler.h"
00011
00012 namespace SDX {
00013 class Attribute;
00014 class Document;
00015 class Node;
00016 class ResourceReader;
00017
00018 namespace Helpers {
00024 class Validator {
00025 public:
00029 Validator();
00030
00034 void setDocumentStructure(SDX::ResourceReader*, bool deleteAfterReading = true);
00035
00039 void setDocumentStructure(SDX::Document*);
00040
00044 bool validate(SDX::Document*);
00045
00049 std::string getError();
00050 private:
00051 struct InfoNode {
00052 SDX::Node* node;
00053
00054 std::map<std::string, std::string> placeholders;
00055 std::set<SDX::Node*> nodesToDrop;
00056 std::set<SDX::Attribute*> attributesToDrop;
00057 };
00058 private:
00059 void setError(std::string);
00060
00061 bool validate(SDX::Node* nodeToValidate, SDX::Node* validationNode);
00062 bool validate(SDX::Attribute* attributeToValidate, SDX::Node* validationNode);
00063 bool process(SDX::Node* validationNode, SDX::Node* customValidationNode, std::vector<SDX::Attribute*>* unnamedAttributes);
00064 bool evaluateIf(SDX::Node* ifNode);
00065 std::string getPlaceholder(std::string name);
00066
00067 std::string m_error;
00068
00069 SDX::Document* m_documentStructure;
00070 std::vector<InfoNode> m_infoNodes;
00071 };
00072 }
00073 }
00074
00075 #endif