Annotation of nono/lib/mystring.h, revision 1.1.1.6

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.