Page Speed Optimization Libraries
1.6.29.3
|
00001 /* 00002 * Copyright 2010 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00070 00071 #ifndef NET_INSTAWEB_UTIL_PUBLIC_URL_TO_FILENAME_ENCODER_H_ 00072 #define NET_INSTAWEB_UTIL_PUBLIC_URL_TO_FILENAME_ENCODER_H_ 00073 00074 #include <cstddef> 00075 00076 #include "net/instaweb/util/public/string.h" 00077 #include "net/instaweb/util/public/string_util.h" 00078 00079 namespace net_instaweb { 00080 00082 class UrlToFilenameEncoder { 00083 public: 00090 static void EncodeSegment( 00091 const StringPiece& filename_prefix, 00092 const StringPiece& escaped_ending, 00093 char dir_separator, 00094 GoogleString* encoded_filename); 00095 00098 static bool Decode(const StringPiece& encoded_filename, 00099 char dir_separator, 00100 GoogleString* decoded_url); 00101 00106 static GoogleString Unescape(const StringPiece& escaped_url); 00107 00108 static const char kEscapeChar; 00109 static const char kTruncationChar; 00110 static const size_t kMaximumSubdirectoryLength; 00111 00112 friend class UrlToFilenameEncoderTest; 00113 00114 private: 00122 static void AppendSegment( 00123 GoogleString* segment, 00124 GoogleString* dest); 00125 }; 00126 00127 } 00128 00129 #endif ///< NET_INSTAWEB_UTIL_PUBLIC_URL_TO_FILENAME_ENCODER_H_