| 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 | |
| 19 | namespace dena { |
| 20 | |
| 21 | inline const char * |
| 22 | memchr_char(const char *s, int c, size_t n) |
| 23 | { |
| 24 | return static_cast<const char *>(memchr(s, c, n)); |
| 25 | } |
| 26 | |
| 27 | inline char * |
| 28 | memchr_char(char *s, int c, size_t n) |
| 29 | { |
| 30 | return static_cast<char *>(memchr(s, c, n)); |
| 31 | } |
| 32 | |
| 33 | string_wref get_token(char *& wp, char *wp_end, char delim); |
| 34 | uint32_t atoi_uint32_nocheck(const char *start, const char *finish); |
| 35 | std::string to_stdstring(uint32_t v); |
| 36 | void append_uint32(string_buffer& buf, uint32_t v); |
| 37 | long long atoll_nocheck(const char *start, const char *finish); |
| 38 | |
| 39 | int errno_string(const char *s, int en, std::string& err_r); |
| 40 | |
| 41 | size_t split(char delim, const string_ref& buf, string_ref *parts, |
| 42 | size_t parts_len); |
| 43 | size_t split(char delim, const string_wref& buf, string_wref *parts, |
| 44 | size_t parts_len); |
| 45 | size_t split(char delim, const string_ref& buf, |
| 46 | std::vector<string_ref>& parts_r); |
| 47 | size_t split(char delim, const string_wref& buf, |
| 48 | std::vector<string_wref>& parts_r); |
| 49 | |
| 50 | }; |
| 51 | |
| 52 | #endif |
| 53 | |
| 54 | |