クラス langedge::PathName

マルチバイトなパス名を扱うクラス. [詳細]

#include <pathname.hpp>

langedge::PathNameに対する継承グラフ

Inheritance graph
[凡例]
langedge::PathNameのコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

Public 型

enum  { PATHNAME_MAXLEN = _MAX_PATH }
 パス長の最大値 [詳細]

Public メソッド

 PathName ()
 デフォルトコンストラクタ
 PathName (const PathCharType *path)
 パス名(Char*)で初期化されるコンストラクタ.
 PathName (const PathStringType &path)
 パス名(String)で初期化されるコンストラクタ.
 PathName (const PathName &path)
 コピーコンストラクタ
const PathNameoperator= (const PathCharType *path)
 パス名(Char*)の代入
const PathNameoperator= (const PathStringType &path)
 パス名(String)の代入
const PathNameoperator= (const PathName &path)
 パス名(PathName)の代入
PathNameoperator+= (const PathCharType *path)
 パス名(Char*)を付加するオペレータ.
PathNameoperator+= (const PathStringType &path)
 パス名(String)を付加するオペレータ.
PathNameoperator+= (const PathName &path)
 パス名(PathName)を付加するオペレータ.
PathName operator+ (const PathCharType *path) const
 与えられたパス名(Char*)を付加した結果のパス名を返す.
PathName operator+ (const PathStringType &path) const
 与えられたパス名(String)を付加した結果のパス名を返す.
PathName operator+ (const PathName &path) const
 与えられたパス名(PathName)を付加した結果のパス名を返す.
bool operator== (const PathCharType *path) const
 等値比較
bool operator== (const PathStringType &path) const
 等値比較
bool operator== (const PathName &path) const
 等値比較
bool operator!= (const PathCharType *path) const
 不等比較
bool operator!= (const PathStringType &path) const
 不等比較
bool operator!= (const PathName &path) const
 不等比較
bool empty () const
 空パスか
size_t length () const
 長さを得る
const PathCharTypec_str () const
 パス名を C-like な文字列で得る
const PathStringTypetoString () const
 パス名を保持する String メンバへの参照を得る
PathCharType getCharAt (size_t n) const
 パス名のn要素目を得る
bool isDosRootDirectory () const
 パスは、DOS形式のルートディレクトリか.
bool isRootDirectory () const
 自パスは、ルートディレクトリか.
bool isAbsolutePath () const
 与えられたパスは、絶対パス形式か.
bool isTailCharPathDelimiter () const
 パス名の末尾がパス区切り文字か.
PathName appendPathDelimiter () const
 自パス名の末尾にパス区切り文字を付加したパスを返す.
PathName chopPathDelimiter () const
 自パス名の末尾のパス区切りを削除したパスを返す.
PathName appendExtension (const PathName &extension) const
 自パスに、拡張子を付加したパスを返す.
PathName appendSuffixAsExtension (const PathName &suffix) const
 自パスに、サフィックスを付加したパスを返す.
PathName removeExtension () const
 自パスから、拡張子を削除したパスを返す.
PathName extractFileName () const
 自パスから、ディレクトリ部を削除して、末尾のファイル名部分のパスを返す.
PathName superDirectory (int level=1) const
 自パスから、下位ディレクトリ部を削除して、上位ディレクトリ部のパスを返す.
PathName parentDirectory () const
 自パスの、親ディレクトリのパスを返す.
PathName canonicalizePath () const
 自パスをフルパス (正規化されたパス) に変換したパスを返す.
PathName fullPath () const
 自パスをフルパス (正規化されたパス) に変換したパスを返す.

Static Public メソッド

static PathCharType delimChar ()
 パス区切り文字を返す.
static const PathStringTypedelimStr ()
 パス区切り文字列を返す.
static bool isDosRootDirectory (const PathStringType &path)
 与えられたパスは、DOS形式のルートディレクトリか.
static bool isRootDirectory (const PathStringType &path)
 与えられたパスは、ルートディレクトリか.
static bool isAbsolutePath (const PathStringType &path)
 与えられたパスは、絶対パス形式か.
static bool isTailCharPathDelimiter (const PathStringType &path)
 与えられたパス名の末尾がパス区切り文字か.
static PathName appendPathDelimiter (const PathStringType &path)
 与えられたパス名の末尾にパス区切り文字を付加したパスを返す.
static PathName chopPathDelimiter (const PathStringType &path)
 与えられたパス名の末尾のパス区切りを削除したパスを返す.
static PathName appendExtension (const PathStringType &path, const PathStringType &extension)
 与えられたパスに、拡張子を付加したパスを返す.
static PathName appendSuffixAsExtension (const PathStringType &path, const PathStringType &suffix)
 与えられたパスに、サフィックスを付加したパスを返す.
static PathName removeExtension (const PathStringType &path)
 与えられたパスから、拡張子を削除したパスを返す.
static PathName extractFileName (const PathStringType &path)
 与えられたパスから、ディレクトリ部を削除して、末尾のファイル名部分のパスを返す.
static PathName joinPathName (const PathStringType &path1, const PathStringType &path2, const PathStringType &path3="", const PathStringType &path4="", const PathStringType &path5="")
 与えられたパス名を結合する.
static PathName superDirectory (const PathStringType &path, int level=1)
 与えられたパスから、下位ディレクトリ部を削除して、上位ディレクトリ部のパスを返す.
static PathName parentDirectory (const PathStringType &path)
 与えられたパスの、親ディレクトリのパスを返す.
static PathName canonicalizePath (const PathStringType &path)
 与えられたパスをフルパス (正規化されたパス) に変換したパスを返す.
static PathName fullPath (const PathStringType &path)
 与えられたパスをフルパス (正規化されたパス) に変換したパスを返す.

構成

class  BufferType

説明

マルチバイトなパス名を扱うクラス.

パス名に対して、結合や、親ディレクトリ取得などの操作を行う。
ShiftJIS環境でパス名を構成する2バイト文字の一部として 0x5C ('\') が使われていても、それをパス区切りとは見なさない。


列挙型

anonymous enum
 

パス長の最大値

列挙型の値:
PATHNAME_MAXLEN 


コンストラクタとデストラクタ

langedge::PathName::PathName  )  [inline]
 

デフォルトコンストラクタ

langedge::PathName::PathName const PathCharType path  )  [inline, explicit]
 

パス名(Char*)で初期化されるコンストラクタ.

引数:
path パス名 (Char*)

langedge::PathName::PathName const PathStringType path  )  [inline, explicit]
 

パス名(String)で初期化されるコンストラクタ.

引数:
path パス名 (String)

langedge::PathName::PathName const PathName path  )  [inline]
 

コピーコンストラクタ


関数

static PathCharType langedge::PathName::delimChar  )  [inline, static]
 

パス区切り文字を返す.

Windows環境なら '\' を返し、それ以外では '/' を返す

static const PathStringType& langedge::PathName::delimStr  )  [inline, static]
 

パス区切り文字列を返す.

Windows環境なら "\" を返し、それ以外では "/" を返す

const PathName& langedge::PathName::operator= const PathCharType path  )  [inline]
 

パス名(Char*)の代入

const PathName& langedge::PathName::operator= const PathStringType path  )  [inline]
 

パス名(String)の代入

const PathName& langedge::PathName::operator= const PathName path  )  [inline]
 

パス名(PathName)の代入

PathName& langedge::PathName::operator+= const PathCharType path  )  [inline]
 

パス名(Char*)を付加するオペレータ.

必要なら、間にパスデリミタを挿入する。

引数:
path 付加されるパス名 (Char*)
戻り値:
pathが付加された自身への参照

PathName& langedge::PathName::operator+= const PathStringType path  )  [inline]
 

パス名(String)を付加するオペレータ.

必要なら、間にパスデリミタを挿入する。

引数:
path 付加されるパス名 (String)
戻り値:
pathが付加された自身への参照

PathName& langedge::PathName::operator+= const PathName path  )  [inline]
 

パス名(PathName)を付加するオペレータ.

必要なら、間にパスデリミタを挿入する。

引数:
path 付加されるパス名 (PathName)
戻り値:
pathが付加された自身への参照

PathName langedge::PathName::operator+ const PathCharType path  )  const [inline]
 

与えられたパス名(Char*)を付加した結果のパス名を返す.

自身は変化しない。

引数:
path 付加するパス名 (Char*)
戻り値:
pathが付加された新しいパス名

PathName langedge::PathName::operator+ const PathStringType path  )  const [inline]
 

与えられたパス名(String)を付加した結果のパス名を返す.

自身は変化しない。

引数:
path 付加するパス名 (String)
戻り値:
pathが付加された新しいパス名

PathName langedge::PathName::operator+ const PathName path  )  const [inline]
 

与えられたパス名(PathName)を付加した結果のパス名を返す.

自身は変化しない。

引数:
path 付加するパス名 (PathName)
戻り値:
pathが付加された新しいパス名

bool langedge::PathName::operator== const PathCharType path  )  const [inline]
 

等値比較

bool langedge::PathName::operator== const PathStringType path  )  const [inline]
 

等値比較

bool langedge::PathName::operator== const PathName path  )  const [inline]
 

等値比較

bool langedge::PathName::operator!= const PathCharType path  )  const [inline]
 

不等比較

bool langedge::PathName::operator!= const PathStringType path  )  const [inline]
 

不等比較

bool langedge::PathName::operator!= const PathName path  )  const [inline]
 

不等比較

bool langedge::PathName::empty  )  const [inline]
 

空パスか

size_t langedge::PathName::length  )  const [inline]
 

長さを得る

const PathCharType* langedge::PathName::c_str  )  const [inline]
 

パス名を C-like な文字列で得る

const PathStringType& langedge::PathName::toString  )  const [inline]
 

パス名を保持する String メンバへの参照を得る

PathCharType langedge::PathName::getCharAt size_t  n  )  const [inline]
 

パス名のn要素目を得る

static bool langedge::PathName::isDosRootDirectory const PathStringType path  )  [inline, static]
 

与えられたパスは、DOS形式のルートディレクトリか.

DOS形式: ドライブ文字:\

引数:
path パス名
戻り値:
true DOS形式のルートディレクトリである
false DOS形式のルートディレクトリではない

bool langedge::PathName::isDosRootDirectory  )  const [inline]
 

パスは、DOS形式のルートディレクトリか.

DOS形式: ドライブ文字:\

戻り値:
true DOS形式のルートディレクトリである
false DOS形式のルートディレクトリではない

static bool langedge::PathName::isRootDirectory const PathStringType path  )  [inline, static]
 

与えられたパスは、ルートディレクトリか.

DOS形式(C:\ など)も含む。

引数:
path パス名
戻り値:
true ルートディレクトリである
false ルートディレクトリではない

bool langedge::PathName::isRootDirectory  )  const [inline]
 

自パスは、ルートディレクトリか.

DOS形式(C:\ など)も含む。

戻り値:
true ルートディレクトリである
false ルートディレクトリではない

static bool langedge::PathName::isAbsolutePath const PathStringType path  )  [inline, static]
 

与えられたパスは、絶対パス形式か.

先頭がパスデリミタで始まるか。(DOS形式(C:\ など)も含む)

引数:
path パス名
戻り値:
true 絶対パス形式である
false 絶対パス形式ではない

bool langedge::PathName::isAbsolutePath  )  const [inline]
 

与えられたパスは、絶対パス形式か.

先頭がパスデリミタで始まるか。(DOS形式(C:\ など)も含む)

戻り値:
true 絶対パス形式である
false 絶対パス形式ではない

static bool langedge::PathName::isTailCharPathDelimiter const PathStringType path  )  [inline, static]
 

与えられたパス名の末尾がパス区切り文字か.

引数:
path パス名
戻り値:
true パス区切り文字である
false パス区切り文字ではない

bool langedge::PathName::isTailCharPathDelimiter  )  const [inline]
 

パス名の末尾がパス区切り文字か.

戻り値:
true パス区切り文字である
false パス区切り文字ではない

static PathName langedge::PathName::appendPathDelimiter const PathStringType path  )  [inline, static]
 

与えられたパス名の末尾にパス区切り文字を付加したパスを返す.

すでに末尾にパス区切り文字が付加されてあれば何もしない

引数:
path パス名
戻り値:
パス区切り文字を付加したパス

PathName langedge::PathName::appendPathDelimiter  )  const [inline]
 

自パス名の末尾にパス区切り文字を付加したパスを返す.

すでに末尾にパス区切り文字が付加されてあれば何もしない

戻り値:
パス区切り文字を付加したパス

static PathName langedge::PathName::chopPathDelimiter const PathStringType path  )  [inline, static]
 

与えられたパス名の末尾のパス区切りを削除したパスを返す.

ルートディレクトリ以外のパスで、末尾にパス区切りが付加されていた場合、 その文字を削除する。

引数:
path パス名
戻り値:
末尾のパス区切り文字を削除したパス

PathName langedge::PathName::chopPathDelimiter  )  const [inline]
 

自パス名の末尾のパス区切りを削除したパスを返す.

ルートディレクトリ以外のパスで、末尾にパス区切りが付加されていた場合、 その文字を削除する。

戻り値:
末尾のパス区切り文字を削除したパス

static PathName langedge::PathName::appendExtension const PathStringType path,
const PathStringType extension
[inline, static]
 

与えられたパスに、拡張子を付加したパスを返す.

付加する拡張子の先頭がピリオドでなければ、自動的にピリオドを挿入する。
extension が空文字列なら、何もしない。

引数:
path パス名
extension 付加する拡張子
戻り値:
拡張子を付加したパス

PathName langedge::PathName::appendExtension const PathName extension  )  const [inline]
 

自パスに、拡張子を付加したパスを返す.

付加する拡張子の先頭がピリオドでなければ、自動的にピリオドを挿入する。
extension が空文字列なら、何もしない。

引数:
extension 付加する拡張子
戻り値:
拡張子を付加したパス

static PathName langedge::PathName::appendSuffixAsExtension const PathStringType path,
const PathStringType suffix
[inline, static]
 

与えられたパスに、サフィックスを付加したパスを返す.

付加するサフィックスにピリオドが含まれていなければ、 そのサフィックスを拡張子とみなして、自動的にピリオドを挿入する。
ピリオドが含まれていれば、そのまま付加する。
例1: foo + c ⇒ foo.c
例2: foo + _bar.c ⇒ foo_bar.c

引数:
path パス名
suffix 付加するサフィックス
戻り値:
サフィックスが付加されたパス

PathName langedge::PathName::appendSuffixAsExtension const PathName suffix  )  const [inline]
 

自パスに、サフィックスを付加したパスを返す.

付加するサフィックスにピリオドが含まれていなければ、 そのサフィックスを拡張子とみなして、自動的にピリオドを挿入する。
ピリオドが含まれていれば、そのまま付加する。
例1: foo + c ⇒ foo.c
例2: foo + _bar.c ⇒ foo_bar.c

引数:
suffix 付加するサフィックス
戻り値:
サフィックスが付加されたパス

static PathName langedge::PathName::removeExtension const PathStringType path  )  [inline, static]
 

与えられたパスから、拡張子を削除したパスを返す.

例1: foo.c ⇒ foo
例2: foo.bar.hoge ⇒ foo.bar

引数:
path パス名
戻り値:
拡張子を削除したパス

PathName langedge::PathName::removeExtension  )  const [inline]
 

自パスから、拡張子を削除したパスを返す.

例1: foo.c ⇒ foo
例2: foo.bar.hoge ⇒ foo.bar

戻り値:
拡張子を削除したパス

static PathName langedge::PathName::extractFileName const PathStringType path  )  [inline, static]
 

与えられたパスから、ディレクトリ部を削除して、末尾のファイル名部分のパスを返す.

例: /foo/bar/hoge.c ⇒ hoge.c を残す。

引数:
path パス名
戻り値:
末尾のファイル名部分

PathName langedge::PathName::extractFileName  )  const [inline]
 

自パスから、ディレクトリ部を削除して、末尾のファイル名部分のパスを返す.

例: /foo/bar/hoge.c ⇒ hoge.c を残す。

戻り値:
末尾のファイル名部分

static PathName langedge::PathName::joinPathName const PathStringType path1,
const PathStringType path2,
const PathStringType path3 = "",
const PathStringType path4 = "",
const PathStringType path5 = ""
[inline, static]
 

与えられたパス名を結合する.

必要なら、間にパスデリミタを挿入する。 逆に、各パスの末尾にパスデリミタが付加されていてもよい。
先頭部のパスが空白なら、パスデリミタから始まるパス (すなわち絶対パス) が生成される。

引数:
path1 先頭部
path2 2番目
path3 3番目
path4 4番目
path5 5番目

static PathName langedge::PathName::superDirectory const PathStringType path,
int  level = 1
[inline, static]
 

与えられたパスから、下位ディレクトリ部を削除して、上位ディレクトリ部のパスを返す.

指定されたレベルだけ、下位ディレクトリ部を削除する。
例1: /foo/bar/hoge.c, level=1 ⇒ /foo/bar
例2: /foo/bar/hoge.c, level=2 ⇒ /foo

引数:
path パス名
level いくつ上のものを返すかを示すレベル。1以下ならすぐ上の親ディレクトリ。
戻り値:
上位ディレクトリのパス
覚え書き:
level だけたどる途中でルートディレクトリに行き着いたら、 ルートディレクトリを返す。
パスが相対パスの場合、途中のノード数より祖先レベルが大きいときは、 空文字列を返す。
結果がルートディレクトリになる場合を除き、末尾にパス区切り文字は付加されない。

PathName langedge::PathName::superDirectory int  level = 1  )  const [inline]
 

自パスから、下位ディレクトリ部を削除して、上位ディレクトリ部のパスを返す.

指定されたレベルだけ、下位ディレクトリ部を削除する。
例1: /foo/bar/hoge.c, level=1 ⇒ /foo/bar
例2: /foo/bar/hoge.c, level=2 ⇒ /foo

引数:
level いくつ上のものを返すかを示すレベル。1以下ならすぐ上の親ディレクトリ。
戻り値:
上位ディレクトリのパス
覚え書き:
level だけたどる途中でルートディレクトリに行き着いたら、 ルートディレクトリを返す。
パスが相対パスの場合、途中のノード数より祖先レベルが大きいときは、 空文字列を返す。
結果がルートディレクトリになる場合を除き、末尾にパス区切り文字は付加されない。

static PathName langedge::PathName::parentDirectory const PathStringType path  )  [inline, static]
 

与えられたパスの、親ディレクトリのパスを返す.

自身を親ディレクトリに変更する。

引数:
path パス名
戻り値:
親ディレクトリのパス。
パスに区切り文字が含まれない場合は、空文字列を返す。

PathName langedge::PathName::parentDirectory  )  const [inline]
 

自パスの、親ディレクトリのパスを返す.

自身を親ディレクトリに変更する。

戻り値:
親ディレクトリのパス。
パスに区切り文字が含まれない場合は、空文字列を返す。

static PathName langedge::PathName::canonicalizePath const PathStringType path  )  [inline, static]
 

与えられたパスをフルパス (正規化されたパス) に変換したパスを返す.

正規化に失敗した場合は、空のパスを返す。

引数:
path パス名
戻り値:
正規化されたパス

static PathName langedge::PathName::fullPath const PathStringType path  )  [inline, static]
 

与えられたパスをフルパス (正規化されたパス) に変換したパスを返す.

正規化に失敗した場合は、空のパスを返す。 canonicalizePath() と同じ。

引数:
path パス名
戻り値:
正規化されたパス

PathName langedge::PathName::canonicalizePath  )  const [inline]
 

自パスをフルパス (正規化されたパス) に変換したパスを返す.

正規化に失敗した場合は、空のパスを返す。

戻り値:
正規化されたパス

PathName langedge::PathName::fullPath  )  const [inline]
 

自パスをフルパス (正規化されたパス) に変換したパスを返す.

正規化に失敗した場合は、空のパスを返す。 canonicalizePath() と同じ。

戻り値:
正規化されたパス


このクラスの説明は次のファイルから生成されました:
LangEdge ライブラリに対してFri May 6 22:43:04 2005に生成されました。  doxygen 1.4.2