//
// cstring.hpp
//
// Header file for the cstring class, which uses a linked list
// to represent a character string.
//
// Computer Science S-111, Harvard University
//

#ifndef CSTRING_HPP
#define CSTRING_HPP

class cstring {
private:
    char firstch;
    cstring *next;

public:
    cstring();
    cstring(char ch);
    
    // These could also have been implemented as member functions.
    friend int length(cstring *str);
    friend char extract(cstring *str, int i);
    friend int index(cstring *str, char ch);
    friend cstring* copystr(cstring *str);
    friend void split(cstring *str, int n, cstring*& head, cstring*& tail);
    friend cstring* point(cstring *str, int i);
    friend void cdelete(cstring*& cstr, int i);
    friend void insert(cstring*& cstr, int i, char ch);
    friend void insert_sorted(cstring*& str, char ch);

    friend cstring* concat(cstring *str1, cstring *str2);
    friend istream& operator >>(istream& s, cstring*& cstr);
    friend ostream& operator <<(ostream& s, cstring *cstr);
};

#endif
