3#ifndef CUDA_BATTERY_STRING_HPP
4#define CUDA_BATTERY_STRING_HPP
14template<
class Allocator=standard_allocator>
22 template <
class Alloc2>
36 data_(raw_string,
strlen(raw_string)+1, alloc) {}
39 template <
class Allocator2>
41 data_(other.data_, alloc) {}
53 data_(other.
data(), other.
size()+1, alloc) {}
68 size_t suffix_len =
strlen(suffix);
72 template <
class IntegerType>
74 if(x == 0) {
return this_type(
"0", alloc); }
76 bool neg = x < IntegerType{0};
81 for(
size_t y = x; y > 0; y = y / 10, ++s) {}
86 for(
size_t i = s-1; x > 0; --i) {
87 buffer[i] =
'0' + (x % 10);
90 return std::move(buffer);
94 template<
class Alloc1,
class Alloc2>
99 template<
class Allocator>
100 CUDA NI string<Allocator> concat(
const char* lhs,
size_t lhs_len,
const char* rhs,
size_t rhs_len,
const Allocator& alloc) {
101 string<Allocator> res(lhs_len + rhs_len, alloc);
103 for(
size_t i = 0; i < lhs_len; ++i, ++k) { res[k] = lhs[i]; }
104 for(
size_t i = 0; i < rhs_len; ++i, ++k) { res[k] = rhs[i]; }
105 return std::move(res);
109template<
class Alloc1,
class Alloc2>
114template<
class Allocator>
119template<
class Allocator>
124template<
class Alloc1,
class Alloc2>
125CUDA bool operator!=(
const string<Alloc1>& lhs,
const string<Alloc2>& rhs) {
126 return !(lhs == rhs);
129template<
class Allocator>
130CUDA bool operator!=(
const char* lhs,
const string<Allocator>& rhs) {
131 return !(lhs == rhs);
134template<
class Allocator>
135CUDA bool operator!=(
const string<Allocator>& lhs,
const char* rhs) {
136 return !(lhs == rhs);
139template<
class Allocator>
144template<
class Allocator>
149template<
class Allocator>
string(string< allocator_type > &&other)=default
CUDA NI bool ends_with(const char *suffix) const
Definition string.hpp:67
CUDA size_t size() const
Definition string.hpp:56
CUDA char * data()
Definition string.hpp:60
CUDA allocator_type get_allocator() const
Definition string.hpp:55
CUDA static NI this_type from_int(IntegerType x, const allocator_type &alloc=allocator_type())
Definition string.hpp:73
CUDA char & operator[](size_t i)
Definition string.hpp:57
CUDA const char & operator[](size_t i) const
Definition string.hpp:58
string(const std::string &other, const allocator_type &alloc=allocator_type())
Definition string.hpp:52
CUDA string(const allocator_type &alloc=allocator_type())
Definition string.hpp:32
CUDA const char * data() const
Definition string.hpp:61
CUDA string(size_t n, const allocator_type &alloc=allocator_type())
Definition string.hpp:26
CUDA string< allocator_type > & operator=(string< allocator_type > other)
Definition string.hpp:47
CUDA string(const string< allocator_type > &other)
Definition string.hpp:44
CUDA friend bool operator==(const string< Alloc1 > &lhs, const string< Alloc2 > &rhs)
Definition string.hpp:110
Allocator allocator_type
Definition string.hpp:19
CUDA string(const char *raw_string, const allocator_type &alloc=allocator_type())
Definition string.hpp:35
char value_type
Definition string.hpp:20
CUDA NI void print() const
Definition string.hpp:63
string< Allocator > this_type
Definition string.hpp:18
CUDA string(const string< Allocator2 > &other, const allocator_type &alloc=allocator_type())
Definition string.hpp:40
CUDA allocator_type get_allocator() const
Definition vector.hpp:214
CUDA size_t size() const
Definition vector.hpp:235
CUDA value_type * data()
Definition vector.hpp:232
Definition algorithm.hpp:10
CUDA string< Allocator > operator+(const string< Allocator > &lhs, const string< Allocator > &rhs)
Definition string.hpp:140
CUDA size_t strlen(const char *str)
Definition utility.hpp:99
CUDA int strcmp(const char *s1, const char *s2)
Definition utility.hpp:108
CUDA bool operator==(const string< Alloc1 > &lhs, const string< Alloc2 > &rhs)
Definition string.hpp:110
#define CUDA
Definition utility.hpp:59
#define NI
Definition utility.hpp:62