Page Speed Optimization Libraries  1.5.27.2
net/instaweb/htmlparse/public/doctype.h
Go to the documentation of this file.
00001 // Copyright 2010 Google Inc.
00016 
00017 #ifndef NET_INSTAWEB_HTMLPARSE_PUBLIC_DOCTYPE_H_
00018 #define NET_INSTAWEB_HTMLPARSE_PUBLIC_DOCTYPE_H_
00019 
00020 #include "net/instaweb/util/public/string_util.h"  
00021 
00022 namespace net_instaweb {
00023 struct ContentType;
00024 
00027 class DocType {
00028  public:
00029   DocType() : doctype_(UNKNOWN) {}
00030   DocType(const DocType& src) : doctype_(src.doctype_) {}
00031   ~DocType() {}
00032 
00033   DocType& operator=(const DocType& src) {
00034     if (&src != this) {
00035       doctype_ = src.doctype_;
00036     }
00037     return *this;
00038   }
00039 
00040   bool operator==(const DocType& other) const {
00041     return doctype_ == other.doctype_;
00042   }
00043 
00044   bool operator!=(const DocType& other) const {
00045     return doctype_ != other.doctype_;
00046   }
00047 
00049   bool IsXhtml() const;
00051   bool IsVersion5() const;
00053 
00054   static const DocType kUnknown;
00055   static const DocType kHTML5;
00056   static const DocType kHTML4Strict;
00057   static const DocType kHTML4Transitional;
00058   static const DocType kXHTML5;
00059   static const DocType kXHTML11;
00060   static const DocType kXHTML10Strict;
00061   static const DocType kXHTML10Transitional;
00062 
00067   bool Parse(const StringPiece& directive,
00068              const ContentType& content_type);
00069 
00070  private:
00071   enum DocTypeEnum {
00072     UNKNOWN = 0,
00073     HTML_5,
00074     HTML_4_STRICT,
00075     HTML_4_TRANSITIONAL,
00076     XHTML_5,
00077     XHTML_1_1,
00078     XHTML_1_0_STRICT,
00079     XHTML_1_0_TRANSITIONAL,
00080     OTHER_XHTML,
00081   };
00082 
00083   explicit DocType(DocTypeEnum doctype) : doctype_(doctype) {}
00084 
00085   DocTypeEnum doctype_;
00086 };
00087 
00088 }  
00089 
00090 #endif  ///< NET_INSTAWEB_HTMLPARSE_PUBLIC_DOCTYPE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines