xtd 0.2.0
Loading...
Searching...
No Matches
basic_string_builder.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../basic_string.hpp"
8#include "../environment.hpp"
12#include <iterator>
15namespace xtd {
17 namespace text {
35 template<class char_t, class traits_t = std::char_traits<char_t>, class allocator_t = xtd::collections::generic::helpers::allocator<char_t >>
36 class basic_string_builder final : public object, public xtd::iequatable<basic_string_builder<char_t, traits_t, allocator_t>> {
37 public:
39
43 using base_type = std::basic_string<char_t, traits_t, allocator_t>;
45 using traits_type = typename base_type::traits_type;
47 using value_type = typename base_type::value_type;
49 using allocator_type = typename base_type::allocator_type;
51 using size_type = typename base_type::size_type;
53 using difference_type = typename base_type::difference_type;
55 using reference = typename base_type::reference;
57 using const_reference = typename base_type::const_reference;
59 using pointer = typename base_type::pointer;
61 using const_pointer = typename base_type::const_pointer;
64 using iterator = typename base_type::iterator;
67 using const_iterator = typename base_type::const_iterator;
69 using reverse_iterator = typename base_type::reverse_iterator;
71 using const_reverse_iterator = typename base_type::const_reverse_iterator;
73
75
85 inline static constexpr size_type npos = base_type::npos;
86
95 static inline constexpr xtd::size bpos = 0;
96
113 static inline constexpr xtd::size epos = npos - 1;
115
117
190 basic_string_builder(const xtd::basic_string<value_type>& value, xtd::size start_index, xtd::size length, xtd::size capacity) : chars_(value.substring(start_index, length).chars()) {self_.capacity(capacity);}
191
194 explicit basic_string_builder(const allocator_type & allocator) noexcept : chars_(allocator) {}
195
198 basic_string_builder(const basic_string_builder & str) noexcept : chars_(str.chars_) {}
202 basic_string_builder(const basic_string_builder & str, const allocator_type & allocator) noexcept : chars_(str.chars_, allocator) {}
203
212
217 basic_string_builder(const basic_string_builder & str, xtd::size index, const allocator_type & allocator) {
219 chars_ = base_type(str.chars_, index, allocator);
220 }
221
229 chars_ = base_type(str.chars_, index, count);
230 }
231
237 basic_string_builder(const basic_string_builder & str, xtd::size index, xtd::size count, const allocator_type & allocator) {
239 chars_ = base_type(str.chars_, index, count, allocator);
240 }
241
244 basic_string_builder(basic_string_builder&& str) noexcept : chars_(std::move(str.chars_)) {}
248 basic_string_builder(basic_string_builder&& str, const allocator_type & allocator) noexcept : chars_(std::move(str.chars_), allocator) {}
249
253 basic_string_builder(xtd::size count, value_type character) : chars_(count, character) {}
258 basic_string_builder(xtd::size count, value_type character, const allocator_type & allocator) : chars_(count, character, allocator) {}
259
263 basic_string_builder(value_type character, xtd::size count) : chars_(count, character) {}
268 basic_string_builder(value_type character, xtd::size count, const allocator_type & allocator) : chars_(count, character, allocator) {}
269
272 basic_string_builder(const_pointer str) { // Can't be explicit by design.
274 chars_ = base_type(str);
275 }
276
283
290
294 basic_string_builder(const_pointer str, xtd::size count, const allocator_type & allocator) : chars_(allocator) {
296 chars_ = base_type(str, count);
297 }
298
301 basic_string_builder(const std::basic_string<value_type>& str) noexcept : chars_(str) {}; // Can't be explicit by design.
305 basic_string_builder(const std::basic_string<value_type>& str, const allocator_type & allocator) noexcept : chars_(str, allocator) {}
306
310 template<class input_iterator_t>
311 basic_string_builder(input_iterator_t first, input_iterator_t last) : chars_(first, last) {}
316 template<class input_iterator_t>
317 basic_string_builder(input_iterator_t first, input_iterator_t last, const allocator_type & allocator) : chars_(first, last, allocator) {}
318
321 basic_string_builder(std::initializer_list<value_type> il) : chars_(il) {}
322
326 basic_string_builder(std::initializer_list<value_type> il, const allocator_type & allocator) : chars_(il, allocator) {}
328
330
334 [[nodiscard]] auto begin() const -> const_iterator {return chars_.begin();}
337 [[nodiscard]] auto begin() -> iterator {return chars_.begin();}
338
347 [[nodiscard]] auto c_str() const noexcept -> const_pointer {return chars_.c_str();}
348
351 [[nodiscard]] auto capacity() const noexcept -> size_type {return chars_.capacity();}
356 chars_.reserve(value);
357 return self_;
358 }
359
362 [[nodiscard]] auto cbegin() const -> const_iterator {return chars_.cbegin();}
363
366 [[nodiscard]] auto chars() const noexcept -> const base_type& {return chars_;}
367
370 [[nodiscard]] auto chars() noexcept -> base_type& {return chars_;}
371
374 [[nodiscard]] auto cend() const -> const_iterator {return chars_.cend();}
375
383 [[nodiscard]] auto data() const noexcept -> const_pointer {return chars_.data();}
391 [[nodiscard]] auto data() noexcept -> pointer {return chars_.data();}
392
395 [[nodiscard]] auto empty() const noexcept -> bool {return chars_.empty();}
396
399 [[nodiscard]] auto end() const -> const_iterator {return chars_.end();}
402 [[nodiscard]] auto end() -> iterator {return chars_.end();}
403
411 [[nodiscard]] auto length() const noexcept -> size_type {return chars_.size();}
421 auto length(size_type value) noexcept -> basic_string_builder& {
422 if (value != length()) chars_.resize(value);
423 return self_;
424 }
425
428 [[nodiscard]] auto max_capacity() const noexcept -> size_type {return max_capacity_;}
429
432 [[nodiscard]] auto size() const noexcept -> size_type {return length();}
434
436
489 auto append(const xtd::basic_string<char_t>& value, size_type start_index, size_type count) -> basic_string_builder& {return append(basic_string_builder {value, start_index, count});}
508 auto append(xtd::boolean value) -> basic_string_builder& {return append_format("{}", value);}
528 auto append(xtd::byte value) -> basic_string_builder& {return append_format("{}", value);}
547 auto append(xtd::decimal value) -> basic_string_builder& {return append_format("{}", value);}
566 auto append(double value) -> basic_string_builder& {return append_format("{}", value);}
585 auto append(xtd::single value) -> basic_string_builder& {return append_format("{}", value);}
604 auto append(xtd::int16 value) -> basic_string_builder& {return append_format("{}", value);}
623 auto append(xtd::int32 value) -> basic_string_builder& {return append_format("{}", value);}
642 auto append(xtd::int64 value) -> basic_string_builder& {return append_format("{}", value);}
662 auto append(xtd::sbyte value) -> basic_string_builder& {return append_format("{}", value);}
681 auto append(xtd::uint16 value) -> basic_string_builder& {return append_format("{}", value);}
700 auto append(xtd::uint32 value) -> basic_string_builder& {return append_format("{}", value);}
719 auto append(xtd::uint64 value) -> basic_string_builder& {return append_format("{}", value);}
742 auto append(value_type value) -> basic_string_builder& {return append(1_z, value);}
762 auto append(value_type value, size_type repeat_count) -> basic_string_builder& {return append(repeat_count, value);}
763
765 auto append(xtd::slong value) -> basic_string_builder& {return append_format("{}", value);}
766 auto append(xtd::ulong value) -> basic_string_builder& {return append_format("{}", value);}
768
779 template<class object_t>
780 auto append(object_t value) -> basic_string_builder& {return append_format("{}", value);}
799 auto append(const basic_string_builder & str) -> basic_string_builder& {return append(str, 0, str.length());}
811 auto append(const basic_string_builder & str, size_type pos) -> basic_string_builder& {return append(str, pos, str.length() - pos);}
826 if (pos > str.length() || pos + count > str.length()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
827 chars_.append(str.chars_, pos, count);
828 return self_;
829 }
830
858 template<class input_iterator_t>
863
871 auto append(std::initializer_list<value_type> ilist) -> basic_string_builder& {return append(basic_string_builder {ilist});}
872
892 template<class ...args_t>
893 auto append_format(const xtd::basic_string<char_t>& format, args_t&& ... args) -> basic_string_builder& {return append(xtd::basic_string<char_t>::format(format, std::forward<args_t>(args)...));}
894
903 template<class collection_t>
913 template<class collection_t>
915
917 template<class value_t>
918 auto append_join(const xtd::basic_string<char_t>& separator, const std::initializer_list<value_t>& values) -> basic_string_builder& {return append_join(separator, xtd::array<value_t>(values));}
919 template<class value_t>
920 auto append_join(value_type separator, const std::initializer_list<value_t>& values) -> basic_string_builder& {return append_join(separator, xtd::array<value_t>(values));}
922
937 auto append_line(const xtd::basic_string<char_t>& value) -> basic_string_builder& {return append(value).append_line();}
938
944 chars_.clear();
945 return self_;
946 }
947
956 auto copy_to(xtd::size source_index, xtd::array<value_type>& destination, xtd::size destination_index, xtd::size destination_count) const -> void {
957 if (source_index > length() || source_index + destination_count > length()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
958 if (destination_index >= destination.length() || destination_index + destination_count > destination.length()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
959 chars_.copy(destination.data() + destination_index, destination_count, source_index);
960 }
961
965 [[nodiscard]] auto equals(const object & obj) const noexcept -> bool override {return dynamic_cast<const basic_string_builder*>(&obj) && equals(static_cast<const basic_string_builder&>(obj));}
970 [[nodiscard]] auto equals(const basic_string_builder & value) const noexcept -> bool override {return chars_ == value.chars_;}
971
978 if (self_.capacity() < capacity) self_.capacity(capacity);
979 return self_.capacity();
980 }
981
984 [[nodiscard]] virtual auto get_base_type() const noexcept -> const base_type& {return chars_;}
985
988 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::size override {return xtd::hash_code::combine(chars_);}
989
999 auto insert(size_type index, const xtd::basic_string<char_t>& value) -> basic_string_builder& {return insert(index, basic_string_builder {value}, 0, value.length());}
1010 auto insert(size_type index, const xtd::basic_string<char_t>& value, size_type count) -> basic_string_builder& {return insert(index, basic_string_builder {value}, 0, count);}
1030 auto insert(size_type index, xtd::byte value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1050 auto insert(size_type index, double value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1060 auto insert(size_type index, xtd::single value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1070 auto insert(size_type index, xtd::int16 value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1080 auto insert(size_type index, xtd::int32 value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1090 auto insert(size_type index, xtd::int64 value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1100 auto insert(size_type index, xtd::sbyte value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1110 auto insert(size_type index, xtd::uint16 value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1120 auto insert(size_type index, xtd::uint32 value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1130 auto insert(size_type index, xtd::uint64 value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1140 auto insert(size_type index, value_type value) -> basic_string_builder& {return insert(index, 1, value);}
1151 auto insert(size_type index, value_type value, size_type repeat_count) -> basic_string_builder& {return insert(index, repeat_count, value);}
1152
1154 auto insert(size_type index, xtd::slong value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1155 auto insert(size_type index, xtd::ulong value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1157
1168 template<class object_t>
1169 auto insert(size_type index, object_t value) -> basic_string_builder& {return insert(index, xtd::basic_string<char_t>::format("{}", value));}
1183
1197 auto insert(size_type index, const_pointer s, size_type count) -> basic_string_builder& {return insert(index, basic_string_builder(s, count));}
1204 auto insert(size_type index, const basic_string_builder & str) -> basic_string_builder& {return insert(index, str, 0, str.length());}
1213 auto insert(size_type index, const basic_string_builder & str, size_type s_index, size_type count) -> basic_string_builder& {
1216 if (s_index > str.length() || s_index + count > str.length()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1217 chars_.insert(index, str.chars_, s_index, count);
1218 return self_;
1219 }
1220
1227 auto insert(size_type index, const basic_string_builder & str, size_type s_index) -> basic_string_builder& {return insert(index, str.chars_, s_index, str.length() - s_index);}
1228
1236 auto remove(size_type start_index, size_type length) -> basic_string_builder& {return erase(start_index, length);}
1237
1243 auto replace(value_type old_char, value_type new_char) noexcept -> basic_string_builder& {return replace(old_char, new_char, 0, length());}
1251 auto replace(value_type old_char, value_type new_char, size_type start_index, size_type count) -> basic_string_builder& {return replace(xtd::basic_string<char_t>(old_char, 1), xtd::basic_string<char_t>(new_char, 1), start_index, count);}
1258 auto replace(const xtd::basic_string<char_t>& old_value, const xtd::basic_string<char_t>& new_value) noexcept -> basic_string_builder& {return replace(old_value, new_value, 0, length());}
1267 auto replace(const xtd::basic_string<char_t>& old_value, const xtd::basic_string<char_t>& new_value, size_type start_index, size_type count) -> basic_string_builder& {
1269 auto old_size = old_value.length();
1270 auto new_size = new_value.length();
1271 auto index = xtd::size {0};
1272 while (true) {
1273 index = chars_.find(old_value, index);
1274 if (index == npos || index >= start_index + count) break;
1275 if (index >= start_index) {
1276 if (old_size == new_size) replace(index, old_size, new_value);
1277 else {
1278 chars_.erase(index, old_value.length());
1279 insert(index, new_value);
1280 }
1281 }
1282 index += new_value.length();
1283 }
1284 return self_;
1285 }
1286
1293 auto replace(size_type pos, size_type count, const basic_string_builder & str) -> basic_string_builder& {
1295 chars_.replace(pos, count, str);
1296 return self_;
1297 }
1306 chars_.replace(first, last, str);
1307 return self_;
1308 }
1309
1319 chars_.replace(pos, count, str, pos2);
1320 return self_;
1321 }
1322
1332 if (pos2 > str.length() || pos2 + count2 > str.length()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1333 chars_.replace(pos, count, str, pos2, count2);
1334 return self_;
1335 }
1336
1345 chars_.replace(pos, count, cstr, count2);
1346 return self_;
1347 }
1348
1358 chars_.replace(first, last, cstr, count2);
1359 return self_;
1360 }
1367 auto replace(size_type pos, size_type count, const_pointer cstr) -> basic_string_builder& {
1368 chars_.replace(pos, count, cstr);
1369 return self_;
1370 }
1378 chars_.replace(first, last, cstr);
1379 return self_;
1380 }
1381
1389 chars_.replace(pos, count, count2, ch);
1390 return self_;
1391 }
1392
1400 chars_.replace(first, last, count2, ch);
1401 return self_;
1402 }
1411 template<class input_iterator_t>
1412 auto replace(const_iterator first, const_iterator last, input_iterator_t first2, input_iterator_t last2) -> basic_string_builder& {
1413 chars_.replace(first, last, first2, last2);
1414 return self_;
1415 }
1416
1423 auto replace(const_iterator first, const_iterator last, std::initializer_list<value_type> ilist) -> basic_string_builder& {
1424 chars_.replace(first, last, ilist);
1425 return self_;
1426 }
1427
1431 //xtd::string to_string() const noexcept override {return __xtd_convert_to_string<char>(chars_);}
1432 [[nodiscard]] auto to_string() const noexcept -> xtd::string override {return xtd::string {chars_};}
1434
1436
1438
1440
1442
1448 auto operator [](xtd::size index) const -> const_reference {
1450 return chars_[index == epos ? length() - 1 : index];
1451 }
1456 auto operator [](xtd::size index) -> reference {
1458 return chars_[index == epos ? length() - 1 : index];
1459 }
1460
1463 operator const base_type& () const noexcept {return chars_;}
1466 operator base_type& () noexcept {return chars_;}
1467
1471 auto operator =(const basic_string_builder & str) noexcept -> basic_string_builder& {
1472 chars_ = str.chars_;
1473 return self_;
1474 }
1475
1479 auto operator =(basic_string_builder&& str) noexcept -> basic_string_builder& {
1480 chars_ = std::move(str.chars_);
1481 return self_;
1482 }
1483
1487 auto operator =(const std::basic_string<value_type>& str) noexcept -> basic_string_builder& {
1488 chars_ = str;
1489 return self_;
1490 }
1491
1495 auto operator =(std::basic_string<value_type>&& str) noexcept -> basic_string_builder& {
1496 chars_ = std::move(str);
1497 return self_;
1498 }
1499
1503 auto operator =(const xtd::basic_string<value_type>& str) noexcept -> basic_string_builder& {
1504 chars_ = str;
1505 return self_;
1506 }
1507
1511 auto operator =(xtd::basic_string<value_type>&& str) noexcept -> basic_string_builder& {
1512 chars_ = std::move(str);
1513 return self_;
1514 }
1515
1520 auto operator =(const_pointer str) -> basic_string_builder& {
1522 chars_ = str;
1523 return self_;
1524 }
1525
1529 auto operator =(value_type character) -> basic_string_builder& {
1530 chars_ = character;
1531 return self_;
1532 }
1533
1537 auto operator =(const std::initializer_list<value_type>& il) -> basic_string_builder& {
1538 chars_ = il;
1539 return self_;
1540 }
1541
1545 auto operator +=(const basic_string_builder & str) -> basic_string_builder& {
1546 chars_ += str.chars_;
1547 return self_;
1548 }
1549
1553 auto operator +=(basic_string_builder&& str) -> basic_string_builder& {
1554 chars_ += std::move(str.chars_);
1555 str.chars_.clear();
1556 return self_;
1557 }
1558
1562 auto operator +=(const_pointer str) -> basic_string_builder& {
1564 chars_ += str;
1565 return self_;
1566 }
1567
1571 auto operator +=(value_type ch) -> basic_string_builder& {
1572 chars_ += ch;
1573 return self_;
1574 }
1575
1580 friend auto operator +(const basic_string_builder & lhs, const basic_string_builder & rhs) -> basic_string_builder {
1581 auto result = lhs;
1582 result += rhs;
1583 return result;
1584 }
1585
1590 friend auto operator +(basic_string_builder&& lhs, basic_string_builder&& rhs) -> basic_string_builder {
1591 auto result = std::move(lhs);
1592 result += std::move(rhs);
1593 return result;
1594 }
1595
1600 friend auto operator +(basic_string_builder&& lhs, const basic_string_builder & rhs) -> basic_string_builder {
1601 auto result = std::move(lhs);
1602 result += rhs;
1603 return result;
1604 }
1605
1610 friend auto operator +(const basic_string_builder & lhs, basic_string_builder&& rhs) -> basic_string_builder {
1611 auto result = lhs;
1612 result += std::move(rhs);
1613 return result;
1614 }
1615
1620 friend auto operator +(const basic_string_builder & lhs, const_pointer rhs) -> basic_string_builder {
1621 auto result = lhs;
1622 result += rhs;
1623 return result;
1624 }
1625
1630 friend auto operator +(basic_string_builder&& lhs, const_pointer rhs) -> basic_string_builder {
1631 auto result = std::move(lhs);
1632 result += rhs;
1633 return result;
1634 }
1635
1640 friend auto operator +(const_pointer lhs, const basic_string_builder & rhs) -> basic_string_builder {
1641 return lhs + rhs.chars_;
1642 }
1643
1648 friend auto operator +(const_pointer lhs, basic_string_builder&& rhs) -> basic_string_builder {
1649 return lhs + std::move(rhs).chars_;
1650 }
1651
1656 friend auto operator +(basic_string_builder & lhs, value_type rhs) -> basic_string_builder {
1657 auto result = lhs;
1658 result += rhs;
1659 return result;
1660 }
1661
1666 friend auto operator +(basic_string_builder&& lhs, value_type rhs) -> basic_string_builder {
1667 auto result = std::move(lhs);
1668 result += rhs;
1669 return result;
1670 }
1671
1676 friend auto operator +(value_type lhs, const basic_string_builder & rhs) -> basic_string_builder {
1677 auto result = basic_string_builder(1, lhs);
1678 result += rhs;
1679 return result;
1680 }
1681
1686 friend auto operator +(value_type lhs, basic_string_builder&& rhs) -> basic_string_builder {
1687 auto result = basic_string_builder(1, lhs);
1688 result += std::move(rhs);
1689 return result;
1690 }
1691
1700 //friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string_builder& str) {return stream << str.to_string().chars_;}
1701 friend auto operator <<(std::ostream& stream, const basic_string_builder & str) -> std::ostream& {return stream << xtd::basic_string<char>(str.chars()).chars();}
1708 friend auto operator <<(std::wostream& stream, const basic_string_builder & str) -> std::wostream& {return stream << xtd::basic_string<xtd::wchar>(str.chars()).chars();}
1709
1718 friend auto operator >>(std::istream& stream, basic_string_builder & str) -> std::istream& {
1719 auto s = std::string {};
1720 stream >> s;
1721 str = xtd::basic_string<value_type>(s).chars();
1722 return stream;
1723 }
1732 friend auto operator >>(std::wistream& stream, basic_string_builder & str) -> std::wistream& {
1733 auto s = std::basic_string<xtd::wchar> {};
1734 stream >> s;
1735 str = xtd::basic_string<value_type>(s).chars();
1736 return stream;
1737 }
1739
1740 private:
1741 base_type chars_;
1742 size_type max_capacity_ = chars_.max_size();
1743 };
1744 }
1745}
Contains xtd::argument_exception exception.
Contains xtd::argument_out_of_range_exception exception.
Contains xtd::basic_string class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents text as a sequence of character units.
Definition basic_string.hpp:66
static xtd::string new_line() noexcept
Gets the newline string defined for this environment.
static xtd::size combine(args_t... values) noexcept
Combines values into a hash code.
Definition hash_code.hpp:70
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
object()=default
Create a new instance of the ultimate base class object.
virtual xtd::string to_string() const
Returns a xtd::string that represents the current object.
Represents a mutable string of characters. This class cannot be inherited.
Definition basic_string_builder.hpp:36
auto chars() const noexcept -> const base_type &
Definition basic_string_builder.hpp:366
typename base_type::size_type size_type
Represents the basic string size type.
Definition basic_string_builder.hpp:51
auto append(const xtd::basic_string< char_t > &value, size_type start_index, size_type count) -> basic_string_builder &
Appends a copy of a specified substring to this instance.
Definition basic_string_builder.hpp:489
auto append(std::initializer_list< value_type > ilist) -> basic_string_builder &
Appends additional characters to the string.
Definition basic_string_builder.hpp:871
auto replace(const_iterator first, const_iterator last, const basic_string_builder &str) -> basic_string_builder &
Replaces, within a substring of this instance, all occurrences of a specified string with another spe...
Definition basic_string_builder.hpp:1305
auto append(size_type count, value_type ch) -> basic_string_builder &
Appends additional characters to the string.
Definition basic_string_builder.hpp:790
auto insert(size_type index, xtd::int32 value) -> basic_string_builder &
Inserts the string representation of a specified 32-bit signed integer into this instance at the spec...
Definition basic_string_builder.hpp:1080
static constexpr size_type npos
Definition basic_string_builder.hpp:85
basic_string_builder(const xtd::basic_string< value_type > &value, xtd::size start_index, xtd::size length, xtd::size capacity)
Initializes a new instance of the xtd::text::basic_string_builder class from the specified substring ...
Definition basic_string_builder.hpp:190
typename base_type::difference_type difference_type
Represents the basic string difference type.
Definition basic_string_builder.hpp:53
auto c_str() const noexcept -> const_pointer
Returns a pointer to a null-terminated character array with data equivalent to those stored in the st...
Definition basic_string_builder.hpp:347
basic_string_builder(input_iterator_t first, input_iterator_t last)
Initializes a new instance of xtd::text::basic_string_builder with specified first and last iterators...
Definition basic_string_builder.hpp:311
auto append(object_t value) -> basic_string_builder &
Appends the string representation of a specified object to this instance.
Definition basic_string_builder.hpp:780
auto insert(size_type index, xtd::single value) -> basic_string_builder &
Inserts the string representation of a specified single into this instance at the specified character...
Definition basic_string_builder.hpp:1060
auto replace(const_iterator first, const_iterator last, const_pointer cstr) -> basic_string_builder &
Replaces the characters in the range [begin() + pos, begin() + std::min(pos + count,...
Definition basic_string_builder.hpp:1377
auto append(double value) -> basic_string_builder &
Appends the string representation of a specified double value to this instance.
Definition basic_string_builder.hpp:566
auto max_capacity() const noexcept -> size_type
Definition basic_string_builder.hpp:428
auto end() const -> const_iterator
Returns an iterator to the character following the last character of the string. This character acts ...
Definition basic_string_builder.hpp:399
typename base_type::traits_type traits_type
Represents the basic string traits type.
Definition basic_string_builder.hpp:45
auto replace(const xtd::basic_string< char_t > &old_value, const xtd::basic_string< char_t > &new_value) noexcept -> basic_string_builder &
Inserts characters into the string.
Definition basic_string_builder.hpp:1258
auto insert(size_type index, xtd::uint16 value) -> basic_string_builder &
Inserts the string representation of a specified 16-bit unsigned integer into this instance at the sp...
Definition basic_string_builder.hpp:1110
basic_string_builder(xtd::size capacity)
Initializes a new instance of the xtd::text::basic_string_builder class using the specified capacity.
Definition basic_string_builder.hpp:137
auto capacity() const noexcept -> size_type
Definition basic_string_builder.hpp:351
auto append_join(const xtd::basic_string< char_t > &separator, const collection_t &values) -> basic_string_builder &
Concatenates and appends the members of a collection, using the specified separator between each memb...
Definition basic_string_builder.hpp:904
basic_string_builder(xtd::size capacity, xtd::size max_capacity)
Initializes a new instance of the xtd::text::basic_string_builder class that starts with a specified ...
Definition basic_string_builder.hpp:152
basic_string_builder(const std::basic_string< value_type > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::text::basic_string_builder with specified string to copy and alloc...
Definition basic_string_builder.hpp:305
auto begin() -> iterator
Returns an iterator to the first character of the string.
Definition basic_string_builder.hpp:337
auto append(const basic_string_builder &str) -> basic_string_builder &
Appends additional characters to the string.
Definition basic_string_builder.hpp:799
basic_string_builder(const xtd::basic_string< value_type > &value)
Initializes a new instance of the xtd::text::basic_string_builder class using the specified string.
Definition basic_string_builder.hpp:161
basic_string_builder(const basic_string_builder &str, xtd::size index, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::text::basic_string_builder with specified substring at index,...
Definition basic_string_builder.hpp:237
auto append(xtd::uint32 value) -> basic_string_builder &
Appends the string representation of a specified 32-bit unsigned integer value to this instance.
Definition basic_string_builder.hpp:700
auto append(input_iterator_t first, input_iterator_t last) -> basic_string_builder &
Appends additional characters to the string.
Definition basic_string_builder.hpp:859
basic_string_builder(const std::basic_string< value_type > &str) noexcept
Initializes a new instance of xtd::text::basic_string_builder with specified string to copy.
Definition basic_string_builder.hpp:301
auto insert(size_type index, value_type value) -> basic_string_builder &
Inserts the string representation of a specified Unicode character into this instance at the specifie...
Definition basic_string_builder.hpp:1140
auto append_join(value_type separator, const collection_t &values) -> basic_string_builder &
Concatenates and appends the members of a collection, using the specified xtd::basic_string_builder::...
Definition basic_string_builder.hpp:914
auto append(xtd::int16 value) -> basic_string_builder &
Appends the string representation of a specified 16-bit signed integer value to this instance.
Definition basic_string_builder.hpp:604
typename base_type::const_pointer const_pointer
Represents the basic string const pointer type.
Definition basic_string_builder.hpp:61
basic_string_builder(value_type character, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::text::basic_string_builder with specified count copies of characte...
Definition basic_string_builder.hpp:268
auto end() -> iterator
Returns an iterator to the character following the last character of the string. This character acts ...
Definition basic_string_builder.hpp:402
basic_string_builder(basic_string_builder &&str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::text::basic_string_builder with specified string to move and alloc...
Definition basic_string_builder.hpp:248
basic_string_builder(const_pointer str, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::text::basic_string_builder with specified substring,...
Definition basic_string_builder.hpp:294
auto append(xtd::sbyte value) -> basic_string_builder &
Appends the string representation of a specified 8-bit signed integer value to this instance.
Definition basic_string_builder.hpp:662
auto replace(size_type pos, size_type count, size_type count2, value_type ch) -> basic_string_builder &
Replaces the characters in the range [begin() + pos, begin() + std::min(pos + count,...
Definition basic_string_builder.hpp:1387
basic_string_builder()=default
Initializes a new instance of xtd::text::basic_string_builder.
auto insert(size_type index, xtd::int64 value) -> basic_string_builder &
Inserts the string representation of a specified 64-bit signed integer into this instance at the spec...
Definition basic_string_builder.hpp:1090
auto insert(size_type index, xtd::uint32 value) -> basic_string_builder &
Inserts the string representation of a specified 32-bit unsigned integer into this instance at the sp...
Definition basic_string_builder.hpp:1120
basic_string_builder(const basic_string_builder &str, xtd::size index, const allocator_type &allocator)
Initializes a new instance of xtd::text::basic_string_builder with specified substring at index and a...
Definition basic_string_builder.hpp:217
auto append(xtd::decimal value) -> basic_string_builder &
Appends the string representation of a specified decimal value to this instance.
Definition basic_string_builder.hpp:547
auto append(xtd::int64 value) -> basic_string_builder &
Appends the string representation of a specified 64-bit signed integer value to this instance.
Definition basic_string_builder.hpp:642
typename base_type::const_reference const_reference
Represents the basic string const referecne type.
Definition basic_string_builder.hpp:57
static constexpr xtd::size epos
Definition basic_string_builder.hpp:113
auto insert(size_type index, const xtd::basic_string< char_t > &value, size_type count) -> basic_string_builder &
Inserts one or more copies of a specified string into this instance at the specified character positi...
Definition basic_string_builder.hpp:1010
auto replace(size_type pos, size_type count, const basic_string_builder &str, size_type pos2, size_type count2) -> basic_string_builder &
Replaces the characters in the range [begin() + pos, begin() + std::min(pos + count,...
Definition basic_string_builder.hpp:1330
auto data() noexcept -> pointer
Returns a pointer to the underlying array serving as character storage. The pointer is such that the ...
Definition basic_string_builder.hpp:391
auto insert(size_type index, value_type value, size_type repeat_count) -> basic_string_builder &
Inserts a specified number of copies of the string representation of a Unicode character to this inst...
Definition basic_string_builder.hpp:1151
static constexpr xtd::size bpos
Definition basic_string_builder.hpp:95
auto insert(size_type index, double value) -> basic_string_builder &
Inserts the string representation of a specified double into this instance at the specified character...
Definition basic_string_builder.hpp:1050
auto append_line() -> basic_string_builder &
Appends the default line terminator to the end of the current xtd::text::basic_string_builder object.
Definition basic_string_builder.hpp:929
auto replace(size_type pos, size_type count, const basic_string_builder &str, size_type pos2) -> basic_string_builder &
Replaces the characters in the range [begin() + pos, begin() + std::min(pos + count,...
Definition basic_string_builder.hpp:1316
auto ensure_capacity(size_type capacity) -> size_type
Ensures that the capacity of this instance of xtd::text::basic_string_builder is at least the specifi...
Definition basic_string_builder.hpp:977
auto append_line(const xtd::basic_string< char_t > &value) -> basic_string_builder &
Appends a copy of the specified string followed by the default line terminator to the end of the curr...
Definition basic_string_builder.hpp:937
auto insert(size_type index, xtd::decimal value) -> basic_string_builder &
Inserts the string representation of a specified 8decimal into this instance at the specified charact...
Definition basic_string_builder.hpp:1040
typename base_type::reference reference
Represents the basic string referecne type.
Definition basic_string_builder.hpp:55
auto append(xtd::boolean value) -> basic_string_builder &
Appends the string representation of a specified boolean value to this instance.
Definition basic_string_builder.hpp:508
basic_string_builder(const xtd::basic_string< value_type > &value, xtd::size capacity)
Initializes a new instance of the xtd::text::basic_string_builder class using the specified string an...
Definition basic_string_builder.hpp:173
auto insert(size_type index, xtd::uint64 value) -> basic_string_builder &
Inserts the string representation of a specified 64-bit unsigned integer into this instance at the sp...
Definition basic_string_builder.hpp:1130
auto chars() noexcept -> base_type &
Returns a reference to the underlying base type.
Definition basic_string_builder.hpp:370
auto append(xtd::single value) -> basic_string_builder &
Appends the string representation of a specified single value to this instance.
Definition basic_string_builder.hpp:585
auto data() const noexcept -> const_pointer
Returns a pointer to the underlying array serving as character storage. The pointer is such that the ...
Definition basic_string_builder.hpp:383
basic_string_builder(basic_string_builder &&str) noexcept
Initializes a new instance of xtd::text::basic_string_builder with specified string to move.
Definition basic_string_builder.hpp:244
auto append(xtd::uint64 value) -> basic_string_builder &
Appends the string representation of a specified 64-bit unsigned integer value to this instance.
Definition basic_string_builder.hpp:719
auto append(const xtd::basic_string< char_t > &value) -> basic_string_builder &
Appends a copy of the specified string to this instance.
Definition basic_string_builder.hpp:457
basic_string_builder(xtd::size count, value_type character)
Definition basic_string_builder.hpp:253
typename base_type::pointer pointer
Represents the basic string pointer type.
Definition basic_string_builder.hpp:59
auto insert(size_type index, xtd::int16 value) -> basic_string_builder &
Inserts the string representation of a specified 16-bit signed integer into this instance at the spec...
Definition basic_string_builder.hpp:1070
auto append(const_pointer s, size_type count) -> basic_string_builder &
Appends additional characters to the string.
Definition basic_string_builder.hpp:840
auto append(xtd::uint16 value) -> basic_string_builder &
Appends the string representation of a specified 16-bit unsigned integer value to this instance.
Definition basic_string_builder.hpp:681
typename base_type::iterator iterator
Represents the basic string iterator type.
Definition basic_string_builder.hpp:64
auto append_format(const xtd::basic_string< char_t > &format, args_t &&... args) -> basic_string_builder &
Appends the string returned by processing a composite format string, which contains zero or more form...
Definition basic_string_builder.hpp:893
auto length(size_type value) noexcept -> basic_string_builder &
Sets or sets the length of the current xtd::text::basic_string_builder object.
Definition basic_string_builder.hpp:421
auto capacity(size_type value) -> basic_string_builder &
Sets the number of characters that the string has currently allocated space for.
Definition basic_string_builder.hpp:354
auto append(const basic_string_builder &str, size_type pos) -> basic_string_builder &
Appends additional characters to the string.
Definition basic_string_builder.hpp:811
basic_string_builder(const basic_string_builder &str, xtd::size index, xtd::size count)
Initializes a new instance of xtd::text::basic_string_builder with specified substring at index and c...
Definition basic_string_builder.hpp:227
basic_string_builder(const_pointer str, xtd::size count)
Initializes a new instance of xtd::text::basic_string_builder with specified substring and count char...
Definition basic_string_builder.hpp:286
basic_string_builder(const basic_string_builder &str) noexcept
Initializes a new instance of xtd::text::basic_string_builder with specified string to copy.
Definition basic_string_builder.hpp:198
auto cend() const -> const_iterator
Returns an iterator to the character following the last character of the string. This character acts ...
Definition basic_string_builder.hpp:374
auto insert(size_type index, const basic_string_builder &str, size_type s_index, size_type count) -> basic_string_builder &
Inserts characters into the string.
Definition basic_string_builder.hpp:1213
basic_string_builder(const_pointer str)
Initializes a new instance of xtd::text::basic_string_builder with specified string to copy.
Definition basic_string_builder.hpp:272
basic_string_builder(const allocator_type &allocator) noexcept
Initializes a new instance of xtd::text::basic_string_builder with specified allocator.
Definition basic_string_builder.hpp:194
auto empty() const noexcept -> bool
Checks if the string has no characters, i.e. whether begin() == end().
Definition basic_string_builder.hpp:395
basic_string_builder(input_iterator_t first, input_iterator_t last, const allocator_type &allocator)
Initializes a new instance of xtd::text::basic_string_builder with specified first and last iterators...
Definition basic_string_builder.hpp:317
basic_string_builder(std::initializer_list< value_type > il)
Initializes a new instance of xtd::text::basic_string_builder with specified initializer list.
Definition basic_string_builder.hpp:321
auto insert(size_type index, xtd::byte value) -> basic_string_builder &
Inserts the string representation of a specified 8-bit unsigned integer into this instance at the spe...
Definition basic_string_builder.hpp:1030
auto equals(const object &obj) const noexcept -> bool override
Determines whether this instance and a specified object, which must also be a xtd::text::basic_string...
Definition basic_string_builder.hpp:965
auto size() const noexcept -> size_type
Returns the number of char_t elements in the string, i.e. std::distance(begin(), end()).
Definition basic_string_builder.hpp:432
basic_string_builder(const basic_string_builder &str, xtd::size index)
Initializes a new instance of xtd::text::basic_string_builder with specified substring at index.
Definition basic_string_builder.hpp:208
auto insert(size_type index, xtd::sbyte value) -> basic_string_builder &
Inserts the string representation of a specified 8-bit signed integer into this instance at the speci...
Definition basic_string_builder.hpp:1100
auto insert(size_type index, const xtd::basic_string< char_t > &value) -> basic_string_builder &
Inserts a string into this instance at the specified character position.
Definition basic_string_builder.hpp:999
auto append(xtd::byte value) -> basic_string_builder &
Appends the string representation of a specified 8-bit unsigned value to this instance.
Definition basic_string_builder.hpp:528
auto append(value_type value) -> basic_string_builder &
Appends the string representation of a specified xtd::text::basic_string_builder::value_type value to...
Definition basic_string_builder.hpp:742
std::basic_string< char_t, traits_t, allocator_t > base_type
Represents the basic string base type.
Definition basic_string_builder.hpp:43
auto append(xtd::int32 value) -> basic_string_builder &
Appends the string representation of a specified 32-bit signed integer value to this instance.
Definition basic_string_builder.hpp:623
auto copy_to(xtd::size source_index, xtd::array< value_type > &destination, xtd::size destination_index, xtd::size destination_count) const -> void
Copies the characters from a specified segment of this instance to a specified segment of a destinati...
Definition basic_string_builder.hpp:956
auto get_hash_code() const noexcept -> xtd::size override
Returns the hash code for this basic_string_builder.
Definition basic_string_builder.hpp:988
auto cbegin() const -> const_iterator
Returns an iterator to the first character of the string.
Definition basic_string_builder.hpp:362
basic_string_builder(std::initializer_list< value_type > il, const allocator_type &allocator)
Initializes a new instance of xtd::text::basic_string_builder with specified initializer list and all...
Definition basic_string_builder.hpp:326
auto clear() -> basic_string_builder &
Removes all characters from the current xtd::text::basic_string_builder instance.
Definition basic_string_builder.hpp:943
auto insert(size_type index, object_t value) -> basic_string_builder &
Inserts the string representation of a specified object into this instance at the specified character...
Definition basic_string_builder.hpp:1169
typename base_type::const_reverse_iterator const_reverse_iterator
Represents the basic string const reverse iterator type.
Definition basic_string_builder.hpp:71
auto append(const_pointer s) -> basic_string_builder &
Appends additional characters to the string.
Definition basic_string_builder.hpp:849
typename base_type::const_iterator const_iterator
Represents the basic string const iterator type.
Definition basic_string_builder.hpp:67
auto begin() const -> const_iterator
Returns an iterator to the first character of the string.
Definition basic_string_builder.hpp:334
auto append(const basic_string_builder &str, size_type pos, size_type count) -> basic_string_builder &
Appends additional characters to the string.
Definition basic_string_builder.hpp:824
typename base_type::allocator_type allocator_type
Represents the basic string allocator type.
Definition basic_string_builder.hpp:49
typename base_type::reverse_iterator reverse_iterator
Represents the basic string reverse iterator type.
Definition basic_string_builder.hpp:69
auto equals(const basic_string_builder &value) const noexcept -> bool override
Determines whether this instance and another specified xtd::text::basic_string_builder object have th...
Definition basic_string_builder.hpp:970
basic_string_builder(const_pointer str, const allocator_type &allocator)
Initializes a new instance of xtd::text::basic_string_builder with specified string to copy,...
Definition basic_string_builder.hpp:279
basic_string_builder(const basic_string_builder &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::text::basic_string_builder with specified string to copy and alloc...
Definition basic_string_builder.hpp:202
auto length() const noexcept -> size_type
Definition basic_string_builder.hpp:411
basic_string_builder(value_type character, xtd::size count)
Initializes a new instance of xtd::text::basic_string_builder with specified count copies of characte...
Definition basic_string_builder.hpp:263
auto insert(size_type index, xtd::boolean value) -> basic_string_builder &
Inserts the string representation of a boolean value into this instance at the specified character po...
Definition basic_string_builder.hpp:1020
virtual auto get_base_type() const noexcept -> const base_type &
Returns the underlying base type.
Definition basic_string_builder.hpp:984
basic_string_builder(xtd::size count, value_type character, const allocator_type &allocator)
Initializes a new instance of xtd::text::basic_string_builder with specified count copies of characte...
Definition basic_string_builder.hpp:258
typename base_type::value_type value_type
Represents the basic string value type.
Definition basic_string_builder.hpp:47
auto insert(size_type index, size_type count, value_type ch) -> basic_string_builder &
Inserts characters into the string.
Definition basic_string_builder.hpp:1177
auto replace(size_type pos, size_type count, const_pointer cstr, size_type count2) -> basic_string_builder &
Replaces the characters in the range [begin() + pos, begin() + std::min(pos + count,...
Definition basic_string_builder.hpp:1343
auto replace(const_iterator first, const_iterator last, input_iterator_t first2, input_iterator_t last2) -> basic_string_builder &
Replaces the characters in the range [begin() + pos, begin() + std::min(pos + count,...
Definition basic_string_builder.hpp:1412
auto append(value_type value, size_type repeat_count) -> basic_string_builder &
Appends a specified number of copies of the string representation of a Unicode character to this inst...
Definition basic_string_builder.hpp:762
Contains xtd::environment class.
xtd::string format(const xtd::string &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition format.hpp:21
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:61
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
@ null_pointer
The pointer is null.
Definition exception_case.hpp:79
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
constexpr xtd::size npos
Represents a value that is not a valid position in a collection.
Definition npos.hpp:26
@ character
Specifies that the text is trimmed to the nearest character.
Definition string_trimming.hpp:21
std::int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
__slong__ slong
Represents a 32-bit or 64-bit signed integer.
Definition slong.hpp:27
null_ptr null
Represents a null pointer value.
std::int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
bool boolean
Represents a boolean.
Definition boolean.hpp:23
__ulong__ ulong
Represents a 32-bit or 64-bit unsigned integer.
Definition ulong.hpp:27
long double decimal
Represents a decimal-precision floating-point number.
Definition decimal.hpp:23
std::uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
std::int16_t int16
Represents a 16-bit signed integer.
Definition int16.hpp:23
std::uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
std::uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
float single
Represents a single-precision floating-point number.
Definition single.hpp:23
@ s
The S key.
Definition console_key.hpp:124
@ separator
The Separator key.
Definition console_key.hpp:172
@ insert
The INS (INSERT) key.
Definition console_key.hpp:62
@ stream
Supports reliable, two-way, connection-based byte streams without the duplication of data and without...
Definition socket_type.hpp:36
Contains xtd::index_out_of_range_exception exception.
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307
const_reference operator[](size_type index) const
Gets the element at the specified zero-based index.
Definition read_only_span.hpp:400
constexpr size_type length() const noexcept
Returns the length of the current read_only_span.
Definition read_only_span.hpp:229
Contains xtd::null_pointer_exception exception.
Contains xtd numeric literals.