Ninja
includes_normalize.h
Go to the documentation of this file.
1 // Copyright 2012 Google Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef INCLUDES_NORMALIZE_H_
16 #define INCLUDES_NORMALIZE_H_
17 
18 #include <string>
19 #include <vector>
20 
21 struct StringPiece;
22 
23 /// Utility functions for normalizing include paths on Windows.
24 /// TODO: this likely duplicates functionality of CanonicalizePath; refactor.
26  /// Normalize path relative to |relative_to|.
27  IncludesNormalize(const std::string& relative_to);
28 
29  // Internal utilities made available for testing, maybe useful otherwise.
30  static std::string AbsPath(StringPiece s, std::string* err);
31  static std::string Relativize(StringPiece path,
32  const std::vector<StringPiece>& start_list,
33  std::string* err);
34 
35  /// Normalize by fixing slashes style, fixing redundant .. and . and makes the
36  /// path |input| relative to |this->relative_to_| and store to |result|.
37  bool Normalize(const std::string& input, std::string* result,
38  std::string* err) const;
39 
40  private:
41  std::string relative_to_;
42  std::vector<StringPiece> split_relative_to_;
43 };
44 
45 #endif // INCLUDES_NORMALIZE_H_
Utility functions for normalizing include paths on Windows.
std::string relative_to_
static std::string AbsPath(StringPiece s, std::string *err)
std::vector< StringPiece > split_relative_to_
bool Normalize(const std::string &input, std::string *result, std::string *err) const
Normalize by fixing slashes style, fixing redundant .
static std::string Relativize(StringPiece path, const std::vector< StringPiece > &start_list, std::string *err)
IncludesNormalize(const std::string &relative_to)
Normalize path relative to |relative_to|.
StringPiece represents a slice of a string whose memory is managed externally.
Definition: string_piece.h:25