ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/atheme_string.h
(Generate patch)

Comparing ermyth/include/atheme_string.h (file contents):
Revision 1.2 by pippijn, Sat Jul 21 01:29:07 2007 UTC vs.
Revision 1.3 by pippijn, Wed Jul 25 01:05:17 2007 UTC

2 * Copyright © 2005 Atheme Development Group 2 * Copyright © 2005 Atheme Development Group
3 * Rights to this code are as documented in doc/pod/license.pod. 3 * Rights to this code are as documented in doc/pod/license.pod.
4 * 4 *
5 * String stuff. 5 * String stuff.
6 * 6 *
7 * $Id: atheme_string.h,v 1.2 2007/07/21 01:29:07 pippijn Exp $ 7 * $Id: atheme_string.h,v 1.3 2007/07/25 01:05:17 pippijn Exp $
8 */ 8 */
9 9
10#ifndef SVS_STRING_H 10#ifndef SVS_STRING_H
11#define SVS_STRING_H 11#define SVS_STRING_H
12
13void assign (char *dst, char const *src, size_t maxlen);
14
15template<size_t N>
16inline void assign (char (&dst)[N], char const *src)
17{
18 assign ((char *)&dst, src, N);
19}
20 12
21#ifndef HAVE_STRLCAT 13#ifndef HAVE_STRLCAT
22extern size_t strlcat (char *dest, char const *src, size_t count); 14extern size_t strlcat (char *dest, char const *src, size_t count);
23#endif 15#endif
24#ifndef HAVE_STRLCPY 16#ifndef HAVE_STRLCPY
25extern size_t strlcpy (char *dest, char const *src, size_t count); 17extern size_t strlcpy (char *dest, char const *src, size_t count);
26#endif 18#endif
27 19
28extern char const *strip (char *line); 20extern char const *strip (char *line);
29 21
30struct string
31{
32 string (size_t size = 32)
33 : m_rep (new char[size]), pos (0), size (size)
34 {
35 }
36
37 ~string ()
38 {
39 delete[] m_rep;
40 }
41
42 void reset ()
43 {
44 m_rep[0] = '\0';
45 pos = 0;
46 }
47
48 char const * const c_str () const
49 {
50 return m_rep;
51 }
52
53 size_t length ()
54 {
55 return pos;
56 }
57
58 string &operator = (char const *rhs)
59 {
60 reset ();
61 append (rhs, strlen (rhs));
62 return *this;
63 }
64
65 int append (char const c);
66 int append_nonul (char c);
67 int append (char const *src, size_t size);
68 int append_nonul (char const *src, size_t size);
69
70 int append_unguarded (char c);
71 int append_unguarded_nonul (char c);
72 int append_unguarded (char const *src, size_t size);
73 int append_unguarded_nonul (char const *src, size_t size);
74
75private:
76 char *m_rep;
77 size_t pos;
78 size_t size;
79};
80
81#endif 22#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines