Advertisement
rudolf222222

Untitled

Nov 5th, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #pragma once
  2. #include <cctype>
  3. #include <cstring>
  4. #include <iostream>
  5. #include <vector>
  6. class String {
  7.  public:
  8.   explicit String();
  9.   explicit String(size_t size, char character);
  10.   String(const char* const_str);
  11.   String(const String& source);
  12.   void Swap(String& src);
  13.   String& operator=(const String& src);
  14.   ~String();
  15.   size_t Size() const;
  16.   size_t& Size();
  17.   size_t& Capacity();
  18.   const char* Data();
  19.   const char* Data() const;
  20.   bool Empty() const;
  21.   char& operator[](size_t index);
  22.   const char& operator[](size_t index) const;
  23.   size_t Capacity() const;
  24.   void Resize(size_t new_size);
  25.   void Resize(size_t new_size, char character);
  26.   void PushBack(char character);
  27.   void Reserve(size_t new_cap);
  28.   void PopBack();
  29.   void ShrinkToFit();
  30.   void Clear();
  31.   char& Front();
  32.   const char& Front() const;
  33.   const char& Back() const;
  34.   char& Back();
  35.   friend std::ostream& operator<<(std::ostream& os, const String& str);
  36.   friend std::istream& operator>>(std::istream& is, String& str);
  37.   String operator+(const String& other) const;
  38.   String& operator+=(const String& other);
  39.   String& operator*=(size_t n);
  40.   String operator*(size_t n) const;
  41.   bool operator==(const String& other) const;
  42.   bool operator<=(const String& other) const;
  43.   bool operator<(const String& other) const;
  44.   bool operator>(const String& other) const;
  45.   bool operator>=(const String& other) const;
  46.   bool operator!=(const String& other) const;
  47.   String Join(const std::vector<String>& strings) const;
  48.   std::vector<String> Split(const char* separator = " ") const;
  49.   void Print() const;
  50.   void Free();
  51.  
  52.  private:
  53.   unsigned long size_;
  54.   unsigned long capacity_;
  55.   char* string_;
  56. };
  57. // void Substr(const char* input, int offset, int len, char* dest);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement