Home | History | Annotate | Download | only in gn
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef TOOLS_GN_OUTPUT_FILE_H_
      6 #define TOOLS_GN_OUTPUT_FILE_H_
      7 
      8 #include <string>
      9 
     10 #include "tools/gn/build_settings.h"
     11 #include "tools/gn/source_file.h"
     12 
     13 // A simple wrapper around a string that indicates the string is a path
     14 // relative to the output directory.
     15 class OutputFile {
     16  public:
     17   OutputFile() : value_() {}
     18   explicit OutputFile(const base::StringPiece& str)
     19       : value_(str.data(), str.size()) {
     20   }
     21 
     22   std::string& value() { return value_; }
     23   const std::string& value() const { return value_; }
     24 
     25   // Converts to a SourceFile by prepending the build directory to the file.
     26   SourceFile GetSourceFile(const BuildSettings* build_settings) const {
     27     return SourceFile(build_settings->build_dir().value() + value_);
     28   }
     29 
     30   bool operator==(const OutputFile& other) const {
     31     return value_ == other.value_;
     32   }
     33   bool operator!=(const OutputFile& other) const {
     34     return value_ != other.value_;
     35   }
     36   bool operator<(const OutputFile& other) const {
     37     return value_ < other.value_;
     38   }
     39 
     40  private:
     41   std::string value_;
     42 };
     43 
     44 #endif  // TOOLS_GN_OUTPUT_FILE_H_
     45