#ifndef CLUSTER_SYMBOL_HH
# define CLUSTER_SYMBOL_HH

# include <stdlib.h>

class Symbol {
public:
  typedef char *iterator;
  typedef char const *const_iterator;

  Symbol();
  Symbol(char const *str);
  Symbol(char c);
  Symbol(Symbol const &other, bool proxy=false);
  
  ~Symbol();

  Symbol &operator= (Symbol const &other);

  int compareTo(Symbol const &other) const;

  bool operator==(Symbol const &other) const;
  bool operator!=(Symbol const &other) const {
    return !operator==(other);
  }
  bool operator< (Symbol const &other) const;
  
  Symbol &operator+= (Symbol const &other);
  Symbol operator+ (Symbol const &other) const;
  

  char const *c_str() const;

  void clear();

  size_t size() const;
  bool empty() const;
  
  size_t find_first_of(size_t pos, char c) const;
  size_t find_first_not_of(size_t pos, char c) const;
  
  Symbol subSymbol(size_t from) const;
  Symbol subSymbol(size_t from, size_t to) const;

  iterator begin() {
    return m_content;
  }
  iterator end() {
    return m_end;
  }

  const_iterator begin() const {
    return m_content;
  }
  const_iterator end() const {
    return m_end;
  }
  
private:
  bool const is_proxy;
  mutable char *m_content;
  mutable char *m_end;

  static char const s_empty;

  char *&content() const {
    return (char *&)m_content;
  }

  explicit Symbol(bool proxy);

  static char *duplicate(char const *str);
  static char *duplicate(char *&str, bool proxy);
  static char *end(char *str);
}; // Symbol

Symbol operator+ (char *a, Symbol const &b);

#endif // CLUSTER_SYMBOL_HH
