Page Speed Optimization Libraries  1.9.32.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
file_load_mapping.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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 
18 
19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_FILE_LOAD_MAPPING_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_FILE_LOAD_MAPPING_H_
21 
22 #include "pagespeed/kernel/base/basictypes.h"
23 #include "pagespeed/kernel/base/manually_ref_counted.h"
24 #include "pagespeed/kernel/base/string.h"
25 #include "pagespeed/kernel/base/string_util.h"
26 #include "pagespeed/kernel/util/re2.h"
27 
28 namespace net_instaweb {
29 
32 class FileLoadMapping : public ManuallyRefCounted {
33  public:
34  virtual ~FileLoadMapping();
35 
38  virtual bool Substitute(const StringPiece& url,
39  GoogleString* filename) const = 0;
40 };
41 
43  public:
44  FileLoadMappingRegexp(const GoogleString& url_regexp,
45  const GoogleString& filename_prefix)
46  : url_regexp_(url_regexp),
47  url_regexp_str_(url_regexp),
48  filename_prefix_(filename_prefix) {}
49 
50  virtual bool Substitute(const StringPiece& url, GoogleString* filename) const;
51 
52  private:
53  const RE2 url_regexp_;
55  const GoogleString url_regexp_str_;
56  const GoogleString filename_prefix_;
57 
58  DISALLOW_COPY_AND_ASSIGN(FileLoadMappingRegexp);
59 };
60 
62  public:
63  FileLoadMappingLiteral(const GoogleString& url_prefix,
64  const GoogleString& filename_prefix)
65  : url_prefix_(url_prefix),
66  filename_prefix_(filename_prefix) {}
67 
68  virtual bool Substitute(const StringPiece& url, GoogleString* filename) const;
69 
70  private:
71  const GoogleString url_prefix_;
72  const GoogleString filename_prefix_;
73 
74  DISALLOW_COPY_AND_ASSIGN(FileLoadMappingLiteral);
75 };
76 
77 }
78 
79 #endif
Definition: file_load_mapping.h:32
Definition: file_load_mapping.h:61
virtual bool Substitute(const StringPiece &url, GoogleString *filename) const =0
Definition: file_load_mapping.h:42
virtual bool Substitute(const StringPiece &url, GoogleString *filename) const
virtual bool Substitute(const StringPiece &url, GoogleString *filename) const