]> git.donarmstrong.com Git - mothur.git/blob - path.h
b04ab74424691407f6a46a48588384ee630404a3
[mothur.git] / path.h
1 //uchime by Robert C. Edgar http://drive5.com/uchime This code is donated to the public domain.\r
2 \r
3 #ifndef path_h\r
4 #define path_h\r
5 \r
6 struct PathData\r
7         {\r
8 private:\r
9         PathData(PathData &);\r
10         PathData &operator=(PathData &);\r
11 \r
12 public:\r
13         char *Start;\r
14         char *Front;\r
15         char *Back;\r
16         unsigned Bytes;\r
17 \r
18 public:\r
19         PathData()\r
20                 {\r
21                 Clear(true);\r
22                 }\r
23         ~PathData()\r
24                 {\r
25                 Free();\r
26                 }\r
27         void Free();\r
28         void Alloc(unsigned MaxLen);\r
29         void Clear(bool ctor = false)\r
30                 {\r
31                 Start = 0;\r
32                 if (ctor)\r
33                         {\r
34                         Front = 0;\r
35                         Back = 0;\r
36                         Bytes = 0;\r
37                         }\r
38                 else\r
39                         Free();\r
40                 }\r
41         void Copy(const PathData &rhs);\r
42         void FromStr(const char *PathStr);\r
43         void Reverse()\r
44                 {\r
45                 asserta(Start != 0);\r
46                 unsigned L = (unsigned) strlen(Start);\r
47                 for (unsigned k = 0; k < L/2; ++k)\r
48                         {\r
49                         char c = Start[k];\r
50                         Start[k] = Start[L-k-1];\r
51                         Start[L-k-1] = c;\r
52                         }\r
53                 }\r
54         void SetEmpty()\r
55                 {\r
56                 Start = 0;\r
57                 }\r
58 \r
59         bool IsEmpty() const\r
60                 {\r
61                 return Start == 0;\r
62                 }\r
63         };\r
64 \r
65 #endif // path_h\r