Advertisement
Guest User

Strig Class Header

a guest
May 4th, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3.  
  4. #ifndef _STRING_LIBRARY_H_
  5. #define _STRING_LIBRARY_H_
  6.  
  7. #include "lib_vector.h"
  8.  
  9. #define MAX_WORD_IN_A_SENTENCE 20
  10. #define MAX_WORD_SIZE 40
  11. #define USE_OLD_MEMORY 1
  12. #define ALLOCATE_NEW_MEMORY 2
  13.  
  14. namespace abj{
  15.  
  16. class String{
  17. private:
  18.   const char* logFile = "log.txt";
  19.   char* storage;
  20.   int curr_size;
  21.   char capitalize(char c) const;
  22.   int compare_string(char *str1, char *str2) const;
  23. public:
  24.   String();
  25.   String(std::string data);
  26.   String(const abj::String& data);
  27.   String(char* data, int FLAG);
  28.   String(const char* data);
  29.   ~String();
  30.  
  31.   int size() const;
  32.   char get(int index) const;
  33.   bool set(int index, char c);
  34.   void initialize(const abj::String& str);
  35.   void initialize(char* str);
  36.   void initialize(const char* str);
  37.   void removeData();
  38.   void insert_char_at_point(int index, char c);
  39.  
  40.   void print() const;
  41.   void capitalize();
  42.  
  43.   char* get_raw_data() const;
  44.   abj::String copy();
  45.  
  46.   // Concatenation
  47.   void concatenate_at_point(abj::String& str, int index, char separator);
  48.   void concatenate_at_point(abj::String& str, int index);
  49.   void concatenate_at_end(abj::String& str, char separator);
  50.   void concatenate_at_end(abj::String& str);
  51.  
  52.   bool equals(abj::String& data) const;
  53.   bool equals(const char* data) const;
  54.   void resize(int size);
  55.  
  56.   char lastChar() const;
  57.   char operator[](int index) const;
  58.   abj::String operator+(const abj::String& str);
  59.   bool operator==(const abj::String& data) const;
  60.   abj::String& operator=(const abj::String& data);
  61.   bool operator>(const abj::String& data) const;
  62.   bool operator<(const abj::String& data) const;
  63.   bool operator<<(const abj::String& data) const;
  64.   void swap(abj::String& data);
  65.  
  66.   void setStorage(char* storage);
  67.   char* getStorage() const;
  68.   void setSize(int newSize);
  69.  
  70.   friend std::ostream& operator<<( std::ostream &output, const abj::String &data ){
  71.     output <<"String size: " << data.curr_size << ", " << data.storage << "\n";
  72.     return output;
  73.   }
  74.  
  75.   static void test_function();
  76. };
  77.  
  78.  
  79. //char** tokenizer_revamp(char* str);
  80. //void print_word_list(char** x);
  81. }
  82. #endif
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement