ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/include/common/string.h
Revision: 1.3
Committed: Thu Aug 30 19:56:20 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +1 -58 lines
Log Message:
- put faultcodes into their own namespace
- removed old files
- limited header garbage in atheme.h
- macros to inline bools for connection_t::is_*
- put some connection_t functions into the connection_t class

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
3     * Rights to this code are as documented in doc/pod/gplicense.pod.
4     *
5     * Various string structures and functions.
6     *
7 pippijn 1.3 * $Id: string.h,v 1.2 2007-08-28 17:08:07 pippijn Exp $
8 pippijn 1.1 */
9    
10 pippijn 1.2 #ifndef ERMYTH_STRING_H
11     #define ERMYTH_STRING_H
12 pippijn 1.1
13     void assign (char *dst, char const *src, size_t maxlen);
14    
15     template<size_t N>
16     inline void assign (char (&dst)[N], char const *src)
17     {
18     assign ((char *)&dst, src, N);
19     }
20    
21 pippijn 1.2 /* static string */
22     struct ststr
23 pippijn 1.1 {
24 pippijn 1.2 ststr (char const * const initstr)
25     : m_rep (initstr)
26 pippijn 1.1 {
27     }
28    
29 pippijn 1.2 ststr (ststr &initstr)
30     : m_rep (initstr)
31     {
32     }
33    
34     char const *c_str () const
35     {
36     return m_rep;
37     }
38    
39     operator char const * () const
40     {
41     return c_str ();
42     }
43    
44     friend std::ostream &operator << (std::ostream &os, ststr const &rhs)
45     {
46     os << rhs.c_str ();
47     return os;
48     }
49    
50     private:
51     char const * const m_rep;
52     };
53    
54 pippijn 1.1 #endif