src/ucx/string.h

changeset 325
a3e63cb21e20
parent 322
fd21d1840dff
child 328
2bf1da3c411e
equal deleted inserted replaced
324:343bff4cc0b5 325:a3e63cb21e20
50 50
51 #include "ucx.h" 51 #include "ucx.h"
52 #include "allocator.h" 52 #include "allocator.h"
53 #include <stddef.h> 53 #include <stddef.h>
54 54
55 /** Shortcut for a <code>sstr_t struct</code> literal. */ 55 /*
56 #define ST(s) { (char*)s, sizeof(s)-1 } 56 * Use this macro to disable the shortcuts if you experience macro collision.
57 */
58 #ifndef UCX_NO_SSTR_SHORTCUTS
59 /**
60 * Shortcut for a <code>sstr_t struct</code>
61 * or <code>scstr_t struct</code> literal.
62 */
63 #define ST(s) { s, sizeof(s)-1 }
57 64
58 /** Shortcut for the conversion of a C string to a <code>sstr_t</code>. */ 65 /** Shortcut for the conversion of a C string to a <code>sstr_t</code>. */
59 #define S(s) sstrn((char*)s, sizeof(s)-1) 66 #define S(s) sstrn(s, sizeof(s)-1)
60 67
68 /** Shortcut for the conversion of a C string to a <code>scstr_t</code>. */
69 #define SC(s) scstrn(s, sizeof(s)-1)
70 #endif /* UCX_NO_SSTR_SHORTCUTS */
71
72 /*
73 * Use this macro to disable the format macros.
74 */
75 #ifndef UCX_NO_SSTR_FORMAT_MACROS
61 /** Expands a sstr_t or scstr_t to printf arguments. */ 76 /** Expands a sstr_t or scstr_t to printf arguments. */
62 #define SFMT(s) (int) (s).length, (s).ptr 77 #define SFMT(s) (int) (s).length, (s).ptr
63 78
64 /** Format specifier for a sstr_t or scstr_t. */ 79 /** Format specifier for a sstr_t or scstr_t. */
65 #define PRIsstr ".*s" 80 #define PRIsstr ".*s"
81 #endif /* UCX_NO_SSTR_FORMAT_MACROS */
66 82
67 #ifdef __cplusplus 83 #ifdef __cplusplus
68 extern "C" { 84 extern "C" {
69 #endif 85 #endif
70 /** 86 /**

mercurial