[go: up one dir, main page]

Menu

[r303]: / libpetey / string_petey.h  Maximize  Restore  History

Download this file

67 lines (53 with data), 2.1 kB

 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
#ifndef STRINGS_INCLUDED
#define STRINGS_INCLUDED
//defines a string type and a set of operators
#include <stdio.h>
#include <iostream>
namespace libpetey {
class string_petey {
//friend std::ostream &operator << (ostream &outfile, string_petey &s);
protected:
char *stuff;
long size;
public:
//constructors and destructors:
string_petey();
string_petey(const char *astring); //construction from char arr
string_petey(const string_petey &astring); //construction from another string
string_petey &operator = (const char *astring); //assignment from char array
string_petey &operator = (const string_petey &astring); //assignment
~string_petey();
//"arithmetic":
string_petey &operator + (const string_petey &string2); //concatination
//comparators:
int cmp (const string_petey &string2); //general...
int operator > (const string_petey &string2);
int operator < (const string_petey &string2);
int operator >= (const string_petey &string2);
int operator <= (const string_petey &string2);
int operator == (const string_petey &string2);
int operator != (const string_petey &string2);
//substrings:
char el(long index);
char operator [] (long index); //get an element of the string
string_petey mid(long start, long length); //get a substring
//separate into substrings base on a delimiter:
string_petey * sep(string_petey &del);
string_petey * sep(char del);
//type conversion:
operator char* ();
operator double ();
//miscellaneous:
void print();
long length();
//io:
long read(FILE *fileptr);
long write(FILE *fileptr);
};
//std::ostream &operator << (std::ostream &outfile, string_petey &s);
//std::istream &operator >> (std::istream &outfile, string_petey &s);
#ifndef __STRING__
typedef string_petey string;
#endif
} //end namespace libpetey
#endif