|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #pragma once
8:
1.1.1.3 root 9: #include "header.h"
1.1.1.4 root 10: #include <vector>
1.1.1.3 root 11:
1.1 root 12: extern std::string string_format(const char *fmt, ...) __printflike(1, 2);
1.1.1.2 root 13:
14: // 先頭の連続する空白文字列を取り除いた新しい文字列を返す
15: extern std::string string_ltrim(const std::string& str);
16:
17: // 末尾の連続する空白文字列を取り除く
18: extern void string_rtrim(std::string& str);
19:
20: // 末尾の連続する空白文字列を取り除く (char *版)
21: extern void rtrim(char *str);
22:
1.1.1.5 ! root 23: // 文字列 str から先頭と末尾の連続する空白文字を取り除いた新しい文字列を返す。
! 24: extern std::string string_trim(const std::string& str);
! 25:
1.1.1.2 root 26: // 文字列中の ASCII 大文字を小文字にした新しい文字列を返す
27: extern std::string string_tolower(const std::string& str);
1.1.1.4 root 28:
29: // 文字列 lhs の先頭が rhs と大文字小文字の区別なしで一致すれば true を返す。
30: // ASCII 専用。
31: extern bool
32: starts_with_ignorecase(const std::string& lhs, const std::string& rhs);
33:
34: // 文字列 str (長さ len) を文字 c で分割したリストを返す
35: // (実際には以下2つのどちらかを呼ぶことになるはず)。
36: //
37: // str に c が含まれてなければ str 全体が1つの要素。
38: // c が str の先頭あるいは末尾にあれば、先頭(末尾) に空要素が出来る。
39: // 連続する c は同一の区切りとはみなさない。
40: // c は ',' のようなのを想定している。
1.1.1.5 ! root 41: // nlimit は戻り値リストの最大要素数で、0 なら指定なし。
! 42: extern std::vector<std::string> string_split(const char *str, int len, char c,
! 43: int nlimit = 0);
1.1.1.4 root 44:
45: // 文字列 str を文字 c で分割したリストを返す。
1.1.1.5 ! root 46: static inline std::vector<std::string> string_split(const char *str, char c,
! 47: int nlimit = 0) {
! 48: return string_split(str, strlen(str), c, nlimit);
1.1.1.4 root 49: }
50: // 文字列 str を文字 c で分割したリストを返す。
51: static inline std::vector<std::string> string_split(const std::string& str,
1.1.1.5 ! root 52: char c, int nlimit = 0) {
! 53: return string_split(str.c_str(), str.size(), c, nlimit);
1.1.1.4 root 54: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.