1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2025-10-18 15:29:24 +00:00
kamokan/src/kamokan_impl/pathname/pathname.hpp
King_DuckZ 6c357f1dc7 Separate Tawashi and Kamokan.
Unit tests are still a bit mixed up, but that should
be simple to split once I have a separate repo for
Tawashi.
2017-06-13 09:36:12 +01:00

67 lines
2.4 KiB
C++

/* Copyright 2015, 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* "dindexer" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef id279E04E31E2C4D98B8C902781A3CE018
#define id279E04E31E2C4D98B8C902781A3CE018
#include "stringpool.hpp"
#include "kakoune/safe_ptr.hh"
#include <vector>
#include <string>
#include <boost/utility/string_view.hpp>
#include <map>
#include <iostream>
namespace mchlib {
class PathName : public Kakoune::SafeCountable {
public:
PathName ( PathName&& ) = default;
PathName ( const PathName& ) = default;
explicit PathName ( boost::string_view parPath );
~PathName ( void ) noexcept = default;
PathName& operator= ( PathName&& ) = default;
bool is_absolute ( void ) const { return m_absolute; }
std::string path ( void ) const;
std::size_t str_path_size ( void ) const;
const std::string& original_path ( void ) const { return (m_original_path ? *m_original_path : m_empty_str); }
std::size_t atom_count ( void ) const;
const boost::string_view operator[] ( std::size_t parIndex ) const;
void join ( const PathName& parOther );
void join ( const char* parOther );
void join ( boost::string_view parOther, const std::string* parSource );
const std::string* get_stringref_source ( std::size_t parIndex ) const;
std::string dirname ( void ) const;
PathName& pop_right ( void );
bool operator!= ( const PathName& parOther ) const;
bool operator== ( const PathName& parOther ) const;
private:
static const std::string m_empty_str;
StringPool<char> m_pool;
const std::string* m_original_path;
bool m_absolute;
};
PathName make_relative_path ( const PathName& parBasePath, const PathName& parOtherPath );
std::ostream& operator<< ( std::ostream& parStream, const PathName& parPath );
const boost::string_view basename ( const PathName& parPath );
} //namespace mchlib
#endif