Guitar
Classes | Functions
misc Namespace Reference

Classes

class  str
 
class  strlist
 

Functions

static int stricmp (char const *s1, char const *s2)
 
static int strnicmp (char const *s1, char const *s2, size_t n)
 
static int stricmp (std::string_view const &s1, std::string_view const &s2)
 
static char const * stristr (const char *haystack, const char *needle)
 
std::vector< std::string_view > splitLinesV (std::string_view const &str)
 
std::vector< std::string_view > splitLinesV (std::vector< char > const &ba)
 
std::vector< std::string_view > splitLinesKeepNewLineV (std::string_view const &str)
 
std::vector< std::string > splitLines (std::string_view const &str)
 
std::vector< std::string_view > splitWords (std::string_view const &text)
 文字列を単語に分割する More...
 
std::vector< std::string_view > split (std::string_view const &sv, char sep)
 
std::string filename (std::string const &path)
 
bool starts_with (const std::string_view &str, const std::string_view &with)
 文字列が指定の文字列で始まるか判定する More...
 
bool starts_with (const std::string_view &str, char with)
 
bool ends_with (const std::string_view &str, const std::string_view &with)
 文字列が指定の文字列で終わるか判定する More...
 
bool ends_with (const std::string_view &str, char with)
 
std::string mid (std::string const &str, int start, int length=-1)
 文字列の一部分を取得する More...
 
std::string replace_backslash_to_slash (std::string_view const &in)
 バックスラッシュをスラッシュに置換する More...
 
std::string normalizePathSeparator (std::string const &str)
 パスの区切り文字を正規化する More...
 
void dump (const uint8_t *ptr, size_t len)
 メモリダンプを16進数で表示する More...
 
bool isText (std::string const &mimetype)
 バイナリデータの内容をヘキサでダンプする More...
 
bool isImage (std::string const &mimetype)
 MIMEタイプが画像ファイルを表すか判定する More...
 
bool isSVG (std::string const &mimetype)
 MIMEタイプがSVG画像を表すか判定する More...
 
bool isPSD (std::string const &mimetype)
 MIMEタイプがPhotoshopファイルを表すか判定する More...
 
bool isPDF (std::string const &mimetype)
 MIMEタイプがPDFファイルを表すか判定する More...
 
std::string makeProxyServerURL (std::string text)
 プロキシサーバーURLを正規化する More...
 
bool isExecutable (const std::string &cmd)
 ファイルが実行可能か判定する More...
 
bool isValidMailAddress (std::string const &email)
 
std::string_view trimmed (std::string_view const &s)
 文字列の両端から空白文字を取り除く More...
 
std::string_view trimQuotes (std::string_view s)
 文字列の両端から空白文字と引用符を取り除く More...
 
std::string_view trimNewLines (std::string_view s)
 文字列の両端から改行文字を取り除く More...
 
std::string bin_to_hex_string (const void *begin, const void *end)
 バイナリデータを16進数文字列に変換する More...
 
std::vector< uint8_t > hex_string_to_bin (std::string_view const &s, const char *sep=nullptr)
 16進数文字列をバイナリデータに変換する More...
 
int compare (uint8_t const *a, size_t n, uint8_t const *b, size_t m)
 2つのバイナリデータを比較する More...
 
int compare (std::vector< uint8_t > const &a, std::vector< uint8_t > const &b)
 2つのバイトベクターを比較する More...
 
std::string toLower (std::string_view const &s)
 
std::string toUpper (std::string_view const &s)
 
static std::vector< std::string > vector_string (std::vector< std::string_view > const &v)
 
template<typename T >
static T toi (std::string_view const &s, size_t *consumed=nullptr)
 
static void append (std::vector< char > *out, char const *ptr, size_t len)
 
static void append (std::vector< char > *out, char c)
 
static void append (std::vector< char > *out, std::string_view const &v)
 
std::string strip_vt (std::string_view const &s)
 VTシーケンスを取り除く More...
 
std::string getProgram (std::string const &cmdline)
 
std::string realpath (const char *path)
 パスを絶対パスに変換する More...
 
std::string realpath (std::string const &path)
 
static QString escape_double_quote_for_file_open (QString const &in)
 
QStringList splitWords (QString const &text)
 文字列を単語に分割する。 More...
 
QString getApplicationDir ()
 アプリケーションのディレクトリパスを取得する More...
 
void drawFrame (QPainter *pr, int x, int y, int w, int h, QColor color_topleft, QColor color_bottomright=QColor())
 矩形のフレームを描画する。 More...
 
QString makeDateTimeString (const QDateTime &dt)
 日時を文字列に変換する More...
 
void setFixedSize (QWidget *w)
 ウィジェットのサイズを固定する More...
 
QPoint contextMenuPos (QWidget *w, QContextMenuEvent *e)
 コンテキストメニューを表示する位置を計算する More...
 
QString abbrevBranchName (QString const &name)
 ブランチ名を短縮形に変換する。 More...
 
QString makeProxyServerURL (QString text)
 プロキシサーバーURLを正規化する More...
 
QString collapseWhitespace (QString const &source)
 文字列内の連続する空白文字を1つのスペースにまとめる。 More...
 
std::wstring convert_str_to_wstr (std::string const &str)
 
std::string convert_wstr_to_str (std::wstring const &str)
 
void parse_args (std::string const &cmd, std::vector< std::string > *out)
 

Function Documentation

◆ abbrevBranchName()

QString misc::abbrevBranchName ( QString const &  name)

ブランチ名を短縮形に変換する。

入力されたブランチ名を短縮形に変換します。ブランチ名の各パス要素の先頭文字を抽出し、 最後のパス要素を除いて短縮形にします。

Parameters
name短縮形に変換する対象のブランチ名。
Returns
短縮されたブランチ名。

◆ append() [1/3]

static void misc::append ( std::vector< char > *  out,
char  c 
)
inlinestatic

◆ append() [2/3]

static void misc::append ( std::vector< char > *  out,
char const *  ptr,
size_t  len 
)
inlinestatic

◆ append() [3/3]

static void misc::append ( std::vector< char > *  out,
std::string_view const &  v 
)
inlinestatic
Here is the call graph for this function:

◆ bin_to_hex_string()

std::string misc::bin_to_hex_string ( const void *  begin,
const void *  end 
)

バイナリデータを16進数文字列に変換する

バイナリデータ(バイト列)を16進数表記の文字列に変換します。 各バイトは2桁の16進数で表現されます(00-FF)。

Parameters
begin変換するバイナリデータの先頭ポインタ
end変換するバイナリデータの終端ポインタ(変換対象に含まれない)
Returns
16進数文字列

◆ collapseWhitespace()

QString misc::collapseWhitespace ( QString const &  source)

文字列内の連続する空白文字を1つのスペースにまとめる。

入力された文字列内の連続する空白文字を1つのスペースにまとめ、結果の文字列を返します。

Parameters
source連続する空白文字をまとめる対象のQStringオブジェクト。
Returns
連続する空白文字が1つのスペースにまとめられたQStringオブジェクト。

◆ compare() [1/2]

int misc::compare ( std::vector< uint8_t > const &  a,
std::vector< uint8_t > const &  b 
)

2つのバイトベクターを比較する

2つのバイトベクターを辞書的に比較します。 内部的にはcompare関数を使用して、ベクターの内容と長さを比較します。

Parameters
a比較する最初のバイトベクター
b比較する2番目のバイトベクター
Returns
a < b の場合は-1、a > b の場合は1、a == b の場合は0
Here is the call graph for this function:

◆ compare() [2/2]

int misc::compare ( uint8_t const *  a,
size_t  n,
uint8_t const *  b,
size_t  m 
)

2つのバイナリデータを比較する

2つのバイト配列を辞書的に比較します。最初に異なるバイトが見つかった時点で その大小関係を返します。同じバイト列で長さが異なる場合は、長い方が大きいと判定されます。

Parameters
a比較する最初のバイト配列
n最初の配列の長さ
b比較する2番目のバイト配列
m2番目の配列の長さ
Returns
a < b の場合は-1、a > b の場合は1、a == b の場合は0

◆ contextMenuPos()

QPoint misc::contextMenuPos ( QWidget *  w,
QContextMenuEvent *  e 
)

コンテキストメニューを表示する位置を計算する

コンテキストメニューイベントに基づいて、メニューを表示する適切な位置を計算します。 マウスによる右クリックの場合はカーソルの位置にオフセット(8,-8)を加え、 それ以外の場合(キーボードでの表示等)はウィジェットの左上から少し離れた位置(4,4)を返します。

Parameters
wコンテキストメニューを表示するウィジェット
eコンテキストメニューイベント
Returns
メニューを表示するグローバル座標位置

◆ convert_str_to_wstr()

std::wstring misc::convert_str_to_wstr ( std::string const &  str)
Here is the call graph for this function:

◆ convert_wstr_to_str()

std::string misc::convert_wstr_to_str ( std::wstring const &  str)
Here is the call graph for this function:

◆ drawFrame()

void misc::drawFrame ( QPainter *  pr,
int  x,
int  y,
int  w,
int  h,
QColor  color_topleft,
QColor  color_bottomright = QColor() 
)

矩形のフレームを描画する。

指定された位置とサイズの矩形のフレームを描画します。フレームの上辺と左辺は、 color_topleftで指定された色で描画され、右辺と下辺はcolor_bottomrightで指定された色で描画されます。

Parameters
prフレームを描画する対象のQPainterオブジェクトへのポインタ。
x矩形の左上隅のX座標。
y矩形の左上隅のY座標。
w矩形の幅。
h矩形の高さ。
color_topleftフレームの上辺と左辺の色。
color_bottomrightフレームの右辺と下辺の色。

◆ dump()

void misc::dump ( const uint8_t *  ptr,
size_t  len 
)

メモリダンプを16進数で表示する

与えられたメモリ領域を16進数でダンプし、表示します。ダンプは、 アドレス、16進数データ(最大16バイトずつ)、ASCII文字列表現の3つの列で構成されます。 表示されない制御文字はピリオド(.)で表示されます。

Parameters
ptrダンプするメモリ領域の先頭ポインタ、nullptrの場合は何も表示しません
lenダンプするメモリ領域の長さ(バイト数)

◆ ends_with() [1/2]

bool misc::ends_with ( const std::string_view &  str,
char  with 
)
Here is the call graph for this function:

◆ ends_with() [2/2]

bool misc::ends_with ( const std::string_view &  str,
const std::string_view &  with 
)

文字列が指定の文字列で終わるか判定する

与えられた文字列が、指定された文字列で終わるかどうかを判定します。

Parameters
strチェックする対象の文字列
with終端に存在するか確認する文字列
Returns
終端がwithで終わる場合はtrue、そうでない場合はfalse

◆ escape_double_quote_for_file_open()

static QString misc::escape_double_quote_for_file_open ( QString const &  in)
inlinestatic

◆ filename()

std::string misc::filename ( std::string const &  path)

◆ getApplicationDir()

QString misc::getApplicationDir ( )

アプリケーションのディレクトリパスを取得する

実行可能ファイルが格納されているディレクトリのパスを返します。 Windowsの場合は'\'、Unixの場合は'/'をパス区切り文字として扱います。

Returns
アプリケーションのディレクトリパス

◆ getProgram()

std::string misc::getProgram ( std::string const &  cmdline)

コマンドラインから実行ファイル名を抜き取る。 例: "C:\Program Files\MyApp\app.exe" –option -> C:\Program Files\MyApp\app.exe

◆ hex_string_to_bin()

std::vector< uint8_t > misc::hex_string_to_bin ( std::string_view const &  s,
const char *  sep = nullptr 
)

16進数文字列をバイナリデータに変換する

16進数表記の文字列をバイナリデータ(バイト列)に変換します。 文字列には2桁の16進数表記(00-FF)を含める必要があります。 オプションで区切り文字を指定することもできます。

Parameters
s変換する16進数文字列
sep区切り文字の文字列。区切り文字はスキップされる。nullptrの場合は区切り文字なし
Returns
変換されたバイナリデータ

◆ isExecutable()

bool misc::isExecutable ( const std::string &  cmd)

ファイルが実行可能か判定する

指定されたファイルパスが実行可能なファイルを指しているか判定します。

Parameters
cmd判定するファイルパス
Returns
実行可能な場合はtrue、そうでない場合はfalse
Here is the call graph for this function:

◆ isImage()

bool misc::isImage ( std::string const &  mimetype)

MIMEタイプが画像ファイルを表すか判定する

与えられたMIMEタイプが画像ファイルを表すか判定します。 PDFファイルや「image/」で始まる全てのMIMEタイプを画像として扱います。

Parameters
mimetype判定するMIMEタイプ文字列
Returns
画像ファイルを表す場合はtrue、そうでない場合はfalse
Here is the call graph for this function:

◆ isPDF()

bool misc::isPDF ( std::string const &  mimetype)

MIMEタイプがPDFファイルを表すか判定する

与えられたMIMEタイプがPDFファイルを表すか判定します。

Parameters
mimetype判定するMIMEタイプ文字列
Returns
PDFファイルを表す場合はtrue、そうでない場合はfalse

◆ isPSD()

bool misc::isPSD ( std::string const &  mimetype)

MIMEタイプがPhotoshopファイルを表すか判定する

与えられたMIMEタイプがAdobe Photoshopのファイルを表すか判定します。

Parameters
mimetype判定するMIMEタイプ文字列
Returns
Photoshopファイルを表す場合はtrue、そうでない場合はfalse

◆ isSVG()

bool misc::isSVG ( std::string const &  mimetype)

MIMEタイプがSVG画像を表すか判定する

与えられたMIMEタイプがSVG画像ファイルを表すか判定します。

Parameters
mimetype判定するMIMEタイプ文字列
Returns
SVG画像を表す場合はtrue、そうでない場合はfalse

◆ isText()

bool misc::isText ( std::string const &  mimetype)

バイナリデータの内容をヘキサでダンプする

QByteArrayの内容をヘキサダンプ形式で表示します。 内部的にはdump(uint8_t const *, size_t)関数を使用して、 QByteArrayの内容をバイト配列としてダンプします。

Parameters
inダンプするQByteArrayへのポインタ、nullptrの場合は何も表示しません

MIMEタイプがテキストファイルを表すか判定する

与えられたMIMEタイプがテキストファイルを表すか判定します。

Parameters
mimetype判定するMIMEタイプ文字列
Returns
テキストファイルを表す場合はtrue、そうでない場合はfalse
Here is the call graph for this function:

◆ isValidMailAddress()

bool misc::isValidMailAddress ( std::string const &  email)
Here is the call graph for this function:

◆ makeDateTimeString()

QString misc::makeDateTimeString ( const QDateTime &  dt)

日時を文字列に変換する

日時情報を読みやすい文字列形式に変換します。 デフォルトではISOフォーマットを使用し、'T'を空白に置換します。

Parameters
dt変換する日時情報
Returns
変換された日時文字列。dt が無効な場合は空文字列

◆ makeProxyServerURL() [1/2]

QString misc::makeProxyServerURL ( QString  text)

プロキシサーバーURLを正規化する

入力されたプロキシサーバーのURLを正規化します。 プロトコルが指定されていない場合は "http://" を付加し、 末尾にスラッシュがない場合は付加します。

Parameters
text正規化するプロキシサーバーURL文字列
Returns
正規化されたプロキシサーバーURL

◆ makeProxyServerURL() [2/2]

std::string misc::makeProxyServerURL ( std::string  text)

プロキシサーバーURLを正規化する

入力されたプロキシサーバーのURLを正規化します。 プロトコルが指定されていない場合は "http://" を付加し、 末尾にスラッシュがない場合は付加します。

Parameters
text正規化するプロキシサーバーURL文字列
Returns
正規化されたプロキシサーバーURL

◆ mid()

std::string misc::mid ( std::string const &  str,
int  start,
int  length = -1 
)

文字列の一部分を取得する

与えられた文字列の指定位置から、指定された長さの部分文字列を抽出します。

Parameters
str対象の文字列
start抽出を開始する位置のインデックス
length抽出する文字の数。負の場合は文字列の最後まで抽出する
Returns
抽出された部分文字列

◆ normalizePathSeparator()

std::string misc::normalizePathSeparator ( std::string const &  str)

パスの区切り文字を正規化する

パスの区切り文字をプラットフォームに合わせて正規化します。 Windowsでは '/' を '\' に変換し、 Unix系プラットフォームでは変換を行いません。

Parameters
str正規化するパス文字列
Returns
正規化されたパス文字列

◆ parse_args()

void misc::parse_args ( std::string const &  cmd,
std::vector< std::string > *  out 
)

◆ realpath() [1/2]

std::string misc::realpath ( const char *  path)

パスを絶対パスに変換する

指定されたパスを絶対パスに変換して返します。パスが存在しない場合や、変換に失敗した場合は空文字列を返します。 '~'で始まるパスは、環境変数HOMEの値を展開して変換します。

Parameters
path変換するパス
Returns
絶対パス。変換に失敗した場合は空文字列。
Here is the call graph for this function:

◆ realpath() [2/2]

std::string misc::realpath ( std::string const &  path)
Here is the call graph for this function:

◆ replace_backslash_to_slash()

std::string misc::replace_backslash_to_slash ( std::string_view const &  in)

バックスラッシュをスラッシュに置換する

与えられた文字列内の全てのバックスラッシュ ('\') をスラッシュ ('/') に置換します。 置換された新しい文字列が返されます。

Parameters
in置換する対象の文字列
Returns
バックスラッシュがスラッシュに置換された新しい文字列

◆ setFixedSize()

void misc::setFixedSize ( QWidget *  w)

ウィジェットのサイズを固定する

ウィジェットのサイズを固定し、リサイズできないようにします。 また、コンテキストヘルプボタンを非表示にし、Windowsの固定サイズダイアログヒントを設定します。

Parameters
wサイズを固定する対象のウィジェット

◆ split()

std::vector< std::string_view > misc::split ( std::string_view const &  sv,
char  sep 
)

◆ splitLines()

std::vector< std::string > misc::splitLines ( std::string_view const &  str)

◆ splitLinesKeepNewLineV()

std::vector< std::string_view > misc::splitLinesKeepNewLineV ( std::string_view const &  str)

◆ splitLinesV() [1/2]

std::vector< std::string_view > misc::splitLinesV ( std::string_view const &  str)

◆ splitLinesV() [2/2]

std::vector< std::string_view > misc::splitLinesV ( std::vector< char > const &  ba)

◆ splitWords() [1/2]

QStringList misc::splitWords ( QString const &  text)

文字列を単語に分割する。

与えられた文字列を単語に分割し、QStringListとして返します。分割は、空白文字を 区切りとして行われます。

Parameters
text分割する対象の文字列。
Returns
分割された単語のリスト。

◆ splitWords() [2/2]

std::vector< std::string_view > misc::splitWords ( std::string_view const &  text)

文字列を単語に分割する

与えられた文字列を単語に分割し、std::string_viewのベクターとして返します。 分割は、空白文字を区切りとして行われます。

Parameters
text分割する対象の文字列
Returns
分割された単語のリスト

◆ starts_with() [1/2]

bool misc::starts_with ( const std::string_view &  str,
char  with 
)
Here is the call graph for this function:

◆ starts_with() [2/2]

bool misc::starts_with ( const std::string_view &  str,
const std::string_view &  with 
)

文字列が指定の文字列で始まるか判定する

与えられた文字列が、指定された文字列で始まるかどうかを判定します。

Parameters
strチェックする対象の文字列
with先頭に存在するか確認する文字列
Returns
先頭がwithで始まる場合はtrue、そうでない場合はfalse

◆ stricmp() [1/2]

static int misc::stricmp ( char const *  s1,
char const *  s2 
)
inlinestatic
Here is the call graph for this function:

◆ stricmp() [2/2]

static int misc::stricmp ( std::string_view const &  s1,
std::string_view const &  s2 
)
inlinestatic
Here is the call graph for this function:

◆ strip_vt()

std::string misc::strip_vt ( std::string_view const &  s)

VTシーケンスを取り除く

文字列からVT(バーチャルターミナル)シーケンスを取り除き、通常のテキストのみを抽出します。 VTシーケンスはエスケープ文字(0x1b)で始まり、特定のパターンに従います。 この関数は、エスケープシーケンスを正しく認識し、それらをスキップしてテキスト部分だけを返します。

Parameters
sVTシーケンスを含む可能性のある入力文字列
Returns
VTシーケンスが取り除かれた通常のテキスト文字列

◆ stristr()

static char const* misc::stristr ( const char *  haystack,
const char *  needle 
)
inlinestatic
Here is the call graph for this function:

◆ strnicmp()

static int misc::strnicmp ( char const *  s1,
char const *  s2,
size_t  n 
)
inlinestatic

◆ toi()

template<typename T >
static T misc::toi ( std::string_view const &  s,
size_t *  consumed = nullptr 
)
inlinestatic

◆ toLower()

std::string misc::toLower ( std::string_view const &  s)

◆ toUpper()

std::string misc::toUpper ( std::string_view const &  s)

◆ trimmed()

std::string_view misc::trimmed ( std::string_view const &  s)

文字列の両端から空白文字を取り除く

文字列の先頭と末尾から空白文字(スペース、タブ、改行など)を削除します。 元の文字列は変更せず、新しいstring_viewを返します。

Parameters
sトリムする文字列
Returns
両端の空白が削除された文字列ビュー

◆ trimNewLines()

std::string_view misc::trimNewLines ( std::string_view  s)

文字列の両端から改行文字を取り除く

文字列の先頭と末尾から改行文字(CR、LF、CRLF)を削除します。 元の文字列は変更せず、新しいstring_viewを返します。 CR+LFの組み合わせは1つの改行として扱われます。

Parameters
sトリムする文字列
Returns
両端の改行が削除された文字列ビュー

◆ trimQuotes()

std::string_view misc::trimQuotes ( std::string_view  s)

文字列の両端から空白文字と引用符を取り除く

文字列の先頭と末尾から空白文字を削除し、その後引用符('"'または'\'')で囲まれている場合は それらの引用符も削除します。元の文字列は変更せず、新しいstring_viewを返します。

Parameters
sトリムする文字列
Returns
両端の空白と引用符が削除された文字列ビュー
Here is the call graph for this function:

◆ vector_string()

static std::vector<std::string> misc::vector_string ( std::vector< std::string_view > const &  v)
inlinestatic