1
2// vim:sw=2:ai
3
4/*
5 * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
6 * See COPYRIGHT.txt for details.
7 */
8
9#ifndef DENA_STRING_UTIL_HPP
10#define DENA_STRING_UTIL_HPP
11
12#include <string>
13#include <string.h>
14#include <stdint.h>
15
16#include "string_buffer.hpp"
17#include "string_ref.hpp"
18
19namespace dena {
20
21inline const char *
22memchr_char(const char *s, int c, size_t n)
23{
24 return static_cast<const char *>(memchr(s, c, n));
25}
26
27inline char *
28memchr_char(char *s, int c, size_t n)
29{
30 return static_cast<char *>(memchr(s, c, n));
31}
32
33string_wref get_token(char *& wp, char *wp_end, char delim);
34uint32_t atoi_uint32_nocheck(const char *start, const char *finish);
35std::string to_stdstring(uint32_t v);
36void append_uint32(string_buffer& buf, uint32_t v);
37long long atoll_nocheck(const char *start, const char *finish);
38
39int errno_string(const char *s, int en, std::string& err_r);
40
41size_t split(char delim, const string_ref& buf, string_ref *parts,
42 size_t parts_len);
43size_t split(char delim, const string_wref& buf, string_wref *parts,
44 size_t parts_len);
45size_t split(char delim, const string_ref& buf,
46 std::vector<string_ref>& parts_r);
47size_t split(char delim, const string_wref& buf,
48 std::vector<string_wref>& parts_r);
49
50};
51
52#endif
53
54