Newer
Older
libj / modules / x-tokenizer / include / string_util.hpp
Nomura Kei on 31 Dec 962 bytes 一時保存
#ifndef XTOKENIZER_STRING_UTIL_HPP
#define XTOKENIZER_STRING_UTIL_HPP
#include <string>
#include <cstring>

namespace xtokenizer
{
    bool startsWith(const std::string &str, const char *prefix, int offset = 0);
    bool startsWith(const std::string &str, const std::string &prefix, int offset = 0);
    int indexOf(const std::string &str, const std::string &needle, int offset);
    int unescapedIndexOf(const std::string &str, const std::string &needle, int offset);
    std::string escapedString(const std::string &str, int offset, int length);

    /**
     * [コンパイル時]
     * 指定された文字列の文字列長を取得します。
     *
     * @param str 文字列
     * @return 文字列長
     */
    constexpr int constexpr_strlen(const char *str)
    {
        int len = 0;
        while (str[len] != '\0')
        {
            len++;
        }
        return len;
    }

} // namespace kscript
#endif // XTOKENIZER_STRING_UTIL_HPP