// Copyright 2010 The Kyua Authors.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions are5// met:6//7// * Redistributions of source code must retain the above copyright8// notice, this list of conditions and the following disclaimer.9// * Redistributions in binary form must reproduce the above copyright10// notice, this list of conditions and the following disclaimer in the11// documentation and/or other materials provided with the distribution.12// * Neither the name of Google Inc. nor the names of its contributors13// may be used to endorse or promote products derived from this software14// without specific prior written permission.15//16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728/// \file utils/fs/path.hpp29/// Provides the utils::fs::path class.30///31/// This is a poor man's reimplementation of the path class provided by32/// Boost.Filesystem, in the sense that it tries to follow the same API but is33/// much simplified.3435#if !defined(UTILS_FS_PATH_HPP)36#define UTILS_FS_PATH_HPP3738#include "utils/fs/path_fwd.hpp"3940#include <string>41#include <ostream>4243namespace utils {44namespace fs {454647/// Representation and manipulation of a file system path.48///49/// Application code should always use this class to represent a path instead of50/// std::string, because this class is more semantically representative, ensures51/// that the values are valid and provides some useful manipulation functions.52///53/// Conversions to and from strings are always explicit.54class path {55/// Internal representation of the path.56std::string _repr;5758public:59explicit path(const std::string&);6061const char* c_str(void) const;62const std::string& str(void) const;6364path branch_path(void) const;65std::string leaf_name(void) const;66path to_absolute(void) const;6768bool is_absolute(void) const;69bool is_parent_of(path) const;70int ncomponents(void) const;7172bool operator<(const path&) const;73bool operator==(const path&) const;74bool operator!=(const path&) const;75path operator/(const std::string&) const;76path operator/(const path&) const;77};787980std::ostream& operator<<(std::ostream&, const path&);818283} // namespace fs84} // namespace utils8586#endif // !defined(UTILS_FS_PATH_HPP)878889