Add PrefixPrinter arguments to the dump routines for MachineFunction and
[oota-llvm.git] / include / llvm / System / Path.h
index f4487c4542dec317e34aad2775702f625070448c..8b603f5ad42c5d5f5d6c5f38f4ec1704daf46482 100644 (file)
@@ -15,6 +15,7 @@
 #define LLVM_SYSTEM_PATH_H
 
 #include "llvm/System/TimeValue.h"
+#include "llvm/Support/raw_ostream.h"
 #include <set>
 #include <string>
 #include <vector>
@@ -180,7 +181,7 @@ namespace sys {
       /// of the path, use the isValid method.
       /// @param p The path to assign.
       /// @brief Construct a Path from a string.
-      explicit Path(const std::string& p) : path(p) {}
+      explicit Path(const std::string& p);
 
       /// This constructor will accept a character range as a path.  No checking
       /// is done on this path to determine if it is valid.  To determine
@@ -188,8 +189,7 @@ namespace sys {
       /// @param StrStart A pointer to the first character of the path name
       /// @param StrLen The length of the path name at StrStart
       /// @brief Construct a Path from a string.
-      explicit Path(const char *StrStart, unsigned StrLen)
-        : path(StrStart, StrStart+StrLen) {}
+      Path(const char *StrStart, unsigned StrLen);
 
     /// @}
     /// @name Operators
@@ -203,19 +203,21 @@ namespace sys {
         return *this;
       }
 
+      /// Makes a copy of \p that to \p this.
+      /// @param \p that A std::string denoting the path
+      /// @returns \p this
+      /// @brief Assignment Operator
+      Path &operator=(const std::string &that);
+
       /// Compares \p this Path with \p that Path for equality.
       /// @returns true if \p this and \p that refer to the same thing.
       /// @brief Equality Operator
-      bool operator==(const Path &that) const {
-        return 0 == path.compare(that.path);
-      }
+      bool operator==(const Path &that) const;
 
       /// Compares \p this Path with \p that Path for inequality.
       /// @returns true if \p this and \p that refer to different things.
       /// @brief Inequality Operator
-      bool operator!=(const Path &that) const {
-        return 0 != path.compare(that.path);
-      }
+      bool operator!=(const Path &that) const;
 
       /// Determines if \p this Path is less than \p that Path. This is required
       /// so that Path objects can be placed into ordered collections (e.g.
@@ -223,9 +225,7 @@ namespace sys {
       /// the std::string::compare method.
       /// @returns true if \p this path is lexicographically less than \p that.
       /// @brief Less Than Operator
-      bool operator<(const Path& that) const {
-        return 0 > path.compare(that.path);
-      }
+      bool operator<(const Path& that) const;
 
     /// @}
     /// @name Path Accessors
@@ -288,7 +288,7 @@ namespace sys {
       const char *c_str() const { return path.c_str(); }
 
       /// size - Return the length in bytes of this path name.
-      unsigned size() const { return path.size(); }
+      size_t size() const { return path.size(); }
 
       /// empty - Returns true if the path is empty.
       unsigned empty() const { return path.empty(); }
@@ -310,6 +310,11 @@ namespace sys {
       /// @brief Determine if the path is absolute.
       bool isAbsolute() const;
 
+      /// This function determines if the path name is absolute, as opposed to
+      /// relative.
+      /// @brief Determine if the path is absolute.
+      static bool isAbsolute(const char *NameStart, unsigned NameLen);
+
       /// This function opens the file associated with the path name provided by
       /// the Path object and reads its magic number. If the magic number at the
       /// start of the file matches \p magic, true is returned. In all other
@@ -460,6 +465,10 @@ namespace sys {
       /// @brief Make the current path name unique in the file system.
       bool makeUnique( bool reuse_current /*= true*/, std::string* ErrMsg );
 
+      /// The current Path name is made absolute by prepending the
+      /// current working directory if necessary.
+      void makeAbsolute();
+
     /// @}
     /// @name Disk Mutators
     /// @{
@@ -706,6 +715,17 @@ namespace sys {
   extern const char PathSeparator;
 }
 
+inline raw_ostream& operator<<(raw_ostream& strm, const sys::Path& aPath) {
+  strm << aPath.toString();
+  return strm;
+}
+
+inline raw_ostream& operator<<(raw_ostream& strm,
+                               const sys::PathWithStatus& aPath) {
+  strm << static_cast<const sys::Path&>(aPath);
+  return strm;
+}
+
 std::ostream& operator<<(std::ostream& strm, const sys::Path& aPath);
 inline std::ostream& operator<<(std::ostream& strm,
                                 const sys::PathWithStatus& aPath) {