Page Speed Optimization Libraries
1.2.24.1
|
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 00025 class DocType { 00026 public: 00027 DocType() : doctype_(UNKNOWN) {} 00028 DocType(const DocType& src) : doctype_(src.doctype_) {} 00029 ~DocType() {} 00030 00031 DocType& operator=(const DocType& src) { 00032 if (&src != this) { 00033 doctype_ = src.doctype_; 00034 } 00035 return *this; 00036 } 00037 00038 bool operator==(const DocType& other) const { 00039 return doctype_ == other.doctype_; 00040 } 00041 00042 bool operator!=(const DocType& other) const { 00043 return doctype_ != other.doctype_; 00044 } 00045 00047 bool IsXhtml() const; 00049 bool IsVersion5() const; 00051 00052 static const DocType kUnknown; 00053 static const DocType kHTML5; 00054 static const DocType kHTML4Strict; 00055 static const DocType kHTML4Transitional; 00056 static const DocType kXHTML5; 00057 static const DocType kXHTML11; 00058 static const DocType kXHTML10Strict; 00059 static const DocType kXHTML10Transitional; 00060 00065 bool Parse(const StringPiece& directive, 00066 const ContentType& content_type); 00067 00068 private: 00069 enum DocTypeEnum { 00070 UNKNOWN = 0, 00071 HTML_5, 00072 HTML_4_STRICT, 00073 HTML_4_TRANSITIONAL, 00074 XHTML_5, 00075 XHTML_1_1, 00076 XHTML_1_0_STRICT, 00077 XHTML_1_0_TRANSITIONAL, 00078 OTHER_XHTML, 00079 }; 00080 00081 explicit DocType(DocTypeEnum doctype) : doctype_(doctype) {} 00082 00083 DocTypeEnum doctype_; 00084 }; 00085 00086 } 00087 00088 #endif ///< NET_INSTAWEB_HTMLPARSE_PUBLIC_DOCTYPE_H_