Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
doctype.h
Go to the documentation of this file.
1 // Copyright 2010 Google Inc.
16 
17 #ifndef PAGESPEED_KERNEL_HTML_DOCTYPE_H_
18 #define PAGESPEED_KERNEL_HTML_DOCTYPE_H_
19 
21 
22 namespace net_instaweb {
23 struct ContentType;
24 
27 class DocType {
28  public:
29  DocType() : doctype_(UNKNOWN) {}
30  DocType(const DocType& src) : doctype_(src.doctype_) {}
31  ~DocType() {}
32 
33  DocType& operator=(const DocType& src) {
34  if (&src != this) {
35  doctype_ = src.doctype_;
36  }
37  return *this;
38  }
39 
40  bool operator==(const DocType& other) const {
41  return doctype_ == other.doctype_;
42  }
43 
44  bool operator!=(const DocType& other) const {
45  return doctype_ != other.doctype_;
46  }
47 
49  bool IsXhtml() const;
51  bool IsVersion5() const;
53 
54  static const DocType kUnknown;
55  static const DocType kHTML5;
56  static const DocType kHTML4Strict;
57  static const DocType kHTML4Transitional;
58  static const DocType kXHTML5;
59  static const DocType kXHTML11;
60  static const DocType kXHTML10Strict;
61  static const DocType kXHTML10Transitional;
62 
67  bool Parse(const StringPiece& directive,
68  const ContentType& content_type);
69 
70  private:
71  enum DocTypeEnum {
72  UNKNOWN = 0,
73  HTML_5,
74  HTML_4_STRICT,
75  HTML_4_TRANSITIONAL,
76  XHTML_5,
77  XHTML_1_1,
78  XHTML_1_0_STRICT,
79  XHTML_1_0_TRANSITIONAL,
80  OTHER_XHTML,
81  };
82 
83  explicit DocType(DocTypeEnum doctype) : doctype_(doctype) {}
84 
85  DocTypeEnum doctype_;
86 };
87 
88 }
89 
90 #endif
bool Parse(const StringPiece &directive, const ContentType &content_type)
Definition: doctype.h:27
bool IsXhtml() const
Return true iff this is a known XHTML doctype (of some version).
Definition: content_type.h:31
bool IsVersion5() const
Return true iff this is an HTML 5 or XHTML 5 doctype.
static const DocType kUnknown
Definition: doctype.h:54