~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/third_party/css_parser/src/webutil/html/htmltagindex.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * Copyright 2010 Google Inc.
3
 
 *
4
 
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 
 * you may not use this file except in compliance with the License.
6
 
 * You may obtain a copy of the License at
7
 
 *
8
 
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 
 *
10
 
 * Unless required by applicable law or agreed to in writing, software
11
 
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 
 * See the License for the specific language governing permissions and
14
 
 * limitations under the License.
15
 
 */
16
 
 
17
 
// Copyright 2006, Google Inc.  All rights reserved.
18
 
// Author: mec@google.com  (Michael Chastain)
19
 
//
20
 
// Map an html tag to a dense index number.
21
 
// Hardwired for speed on builtin tags.
22
 
// Caller can add tags on top of the builtins.
23
 
// Caller can choose case-sensitive or case-insensitive.
24
 
//
25
 
// TODO(mec): merge this with webutil/html/htmltag
26
 
 
27
 
#ifndef WEBUTIL_HTML_HTMLTAGINDEX_H__
28
 
#define WEBUTIL_HTML_HTMLTAGINDEX_H__
29
 
 
30
 
#include <string.h>
31
 
#include <string>
32
 
#include "string_using.h"
33
 
 
34
 
#include "base/basictypes.h"
35
 
#include "base/integral_types.h"
36
 
#include "base/macros.h"
37
 
#include "base/scoped_ptr.h"
38
 
#include "util/gtl/dense_hash_map.h"
39
 
#include "webutil/html/htmltagenum.h"
40
 
 
41
 
class HtmlTagIndex {
42
 
 public:
43
 
  HtmlTagIndex();
44
 
  ~HtmlTagIndex();
45
 
 
46
 
  // Add a tag and return its index.  It is okay to add a builtin
47
 
  // tag or to add the same tag more than once.
48
 
  int AddHtmlTag(const char* tag, int length);
49
 
  int AddHtmlTag(const char* tag) {
50
 
    return AddHtmlTag(tag, strlen(tag));
51
 
  }
52
 
 
53
 
  // Find returns a value in the half-open range [0..GetIndexMax()).
54
 
  // 0 == unknown tag.
55
 
  COMPILE_ASSERT(kHtmlTagUnknown == 0, unknown_tag_equals_zero);
56
 
  int FindHtmlTag(const char* tag, int length) const;
57
 
  int FindHtmlTag(const char* tag) const {
58
 
    return FindHtmlTag(tag, strlen(tag));
59
 
  }
60
 
 
61
 
  // Return the half-open upper bound on lookup return value.
62
 
  // If GetIndexMax returns 10, then find will return [0..9).
63
 
  int GetIndexMax() const {
64
 
    return index_max_;
65
 
  }
66
 
 
67
 
  // Set case sensitivity.  This cannot be done after any calls to AddHtmlTag.
68
 
  void SetCaseSensitive(bool case_sensitive);
69
 
  bool IsCaseSensitive() const {
70
 
    return case_sensitive_;
71
 
  }
72
 
 
73
 
 private:
74
 
  // Case sensitive stuff.
75
 
  bool case_sensitive_fixed_;
76
 
  bool case_sensitive_;
77
 
  uint32 case_mask_1_;
78
 
  uint32 case_mask_2_;
79
 
  uint32 case_mask_3_;
80
 
  uint32 case_mask_4_;
81
 
  uint64 case_mask_5_;
82
 
  uint64 case_mask_6_;
83
 
  uint64 case_mask_7_;
84
 
  uint64 case_mask_8_;
85
 
 
86
 
  int index_max_;
87
 
  typedef dense_hash_map<string, int> CustomTagMap;
88
 
  scoped_ptr<CustomTagMap> custom_tag_map_;
89
 
 
90
 
  DISALLOW_COPY_AND_ASSIGN(HtmlTagIndex);
91
 
};
92
 
 
93
 
#endif  // WEBUTIL_HTML_HTMLTAGINDEX_H__