summaryrefslogtreecommitdiff
path: root/include/BString.h
blob: c4703f088ce94ac9ce628f06cb63943a42c0593f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef __STRING_H__
#define __STRING_H__

#include <string.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <Exceptions.h>
#include <generic.h>

struct ugly_string {
    const char * p;
};

class String : public Base {
  public:
      String(const String &);
      String(const char * = "");
      String(char);
      String(int);
      String(unsigned int);
      String(int64);
      String(uint64);
      String(double);
      ~String();
    const char * set(const char *, va_list);
    const char * set(const char *, ...);
    const char * set(const ugly_string &, ...);
    int scanf(const char *, ...) const;
    int scanf(const ugly_string &, ...) const;
    const char * to_charp(size_t = 0, ssize_t = -1) const;
    String extract(size_t = 0, ssize_t = -1) const;
    char * strdup(size_t = 0, ssize_t = -1) const;
    int to_int() const;
    double to_double() const;
    String to_sqldate() const;
    String to_sqltime() const;
    String from_sqldate() const;
    String from_sqltime() const;
    double datedif(const String &) const;
    bool is_date() const;
    bool is_number() const;
    bool is_float() const;
    bool is_time() const;
    size_t strlen() const;
    ssize_t strchr(char, size_t = 0) const;
    ssize_t strrchr(char) const;
    ssize_t strstr(const String &) const;
    int strchrcnt(char) const;
    String ltrim() const;
    String rtrim() const;
    String trim() const;
    String & operator=(const String &);
    String operator+(const String &) const;
    String & operator+=(const String &);
    bool operator!=(const String &) const;
    bool operator==(const String &) const;
    bool operator<=(const String &) const;
    bool operator>=(const String &) const;
    bool operator<(const String &) const;
    bool operator>(const String &) const;
    char operator[](size_t i) const;
    char & operator[](size_t i);
    operator ugly_string() const;
    String & toupper();
    String & tolower();

  private:
      String(int hs, char *);
    static char t[];
    char * str;
    size_t siz;
};

std::ostream & operator<<(std::ostream &, const String &);
std::istream & operator>>(std::istream &, String &);

String operator+(const char *, const String &);

#endif