00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00048 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_FUNCTIONALS
00049 #define STLSOFT_INCL_STLSOFT_STRING_HPP_FUNCTIONALS
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define STLSOFT_VER_STLSOFT_STRING_HPP_FUNCTIONALS_MAJOR 2
00053 # define STLSOFT_VER_STLSOFT_STRING_HPP_FUNCTIONALS_MINOR 2
00054 # define STLSOFT_VER_STLSOFT_STRING_HPP_FUNCTIONALS_REVISION 4
00055 # define STLSOFT_VER_STLSOFT_STRING_HPP_FUNCTIONALS_EDIT 32
00056 #endif
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00073 # include <stlsoft/stlsoft.h>
00074 #endif
00075 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
00076 # include <stlsoft/shims/access/string.hpp>
00077 #endif
00078 #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
00079 # include <stlsoft/util/std/iterator_helper.hpp>
00080 #endif
00081 #ifndef _STLSOFT_STRING_FUNCTIONALS_NO_STD
00082 # include <functional>
00083 #else
00084 # error Now need to write that std_binary_function stuff!!
00085 #endif
00086
00087 #ifndef STLSOFT_INCL_H_STRING
00088 # define STLSOFT_INCL_H_STRING
00089 # include <string.h>
00090 #endif
00091 #ifndef STLSOFT_INCL_H_WCHAR
00092 # define STLSOFT_INCL_H_WCHAR
00093 # include <wchar.h>
00094 #endif
00095
00096
00097
00098
00099
00100 #ifndef _STLSOFT_NO_NAMESPACE
00101 namespace stlsoft
00102 {
00103 #endif
00104
00105 #ifdef __SYNSOFT_DBS_COMPILER_SUPPORTS_PRAGMA_MESSAGE
00106 # pragma message(_sscomp_fileline_message("TODO: Need a function that can do quoting (or anything else)"))
00107 #endif
00108
00109
00110
00111
00112
00118 template <ss_typename_param_k S>
00119 struct quoter
00120 : public stlsoft_ns_qual_std(unary_function)<char const*, void>
00121 {
00122 public:
00123 S operator()(S const& s) const
00124 {
00125 if(NULL != ::strpbrk(c_str_ptr(s), " \t\""))
00126 {
00127
00128 if(NULL != ::strchr(c_str_ptr(s), '"'))
00129 {
00130 return s;
00131 }
00132 else
00133 {
00134 return '"' + s + '"';
00135 }
00136 }
00137 else
00138 {
00139 return s;
00140 }
00141 }
00142 };
00143
00144 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00145
00152 template <ss_typename_param_k C>
00153 struct string_begins_with_function
00154 : public stlsoft_ns_qual_std(unary_function)<C const*, ss_bool_t>
00155 {
00156 public:
00157
00158 public:
00159 string_begins_with_function(C const* prefix)
00160 : m_prefix(prefix)
00161 , m_prefixLen(stlsoft::c_str_len(m_prefix))
00162 {}
00163
00164 public:
00165 ss_bool_t operator ()(C const* line) const
00166 {
00167 return 0 == ::strncmp(line, m_prefix, m_prefixLen);
00168 }
00169 template <ss_typename_param_k S>
00170 ss_bool_t operator ()(S const& line) const
00171 {
00172 return operator ()(c_str_ptr(line));
00173 }
00174
00175 private:
00176 C const* const m_prefix;
00177 const ss_size_t m_prefixLen;
00178 };
00179
00184 template <ss_typename_param_k C>
00185 inline string_begins_with_function<C> string_begins_with(C const* prefix)
00186 {
00187 return string_begins_with_function<C>(prefix);
00188 }
00189
00190 #endif
00191
00192
00193
00194
00195
00196 #if 0
00197
00203 template< ss_typename_param_k C
00204 >
00205
00206 struct string_equal
00207 : public stlsoft_ns_qual_std(binary_function)<C const*, C const*, ss_bool_t>
00208 {
00209 public:
00210 template< ss_typename_param_k S0
00211 , ss_typename_param_k S1
00212 >
00213 ss_bool_t operator ()(S0 const& s0, S1 const& s1) const
00214 {
00215 return compare_(stlsoft_ns_qual(c_str_data)(s0)
00216 , stlsoft_ns_qual(c_str_len)(s0)
00217 , stlsoft_ns_qual(c_str_data)(s1)
00218 , stlsoft_ns_qual(c_str_len)(s1));
00219 }
00220
00221 private:
00222 static ss_bool_t compare_(ss_char_a_t const* p0, ss_size_t l0, ss_char_a_t const* p1, ss_size_t l1)
00223 {
00224 return (l0 != l1) ? false : 0 == ::strncmp(p0, p1, l0);
00225 }
00226 static ss_bool_t compare_(ss_char_w_t const* p0, ss_size_t l0, ss_char_w_t const* p1, ss_size_t l1)
00227 {
00228 return (l0 != l1) ? false : 0 == ::wcsncmp(p0, p1, l0);
00229 }
00230 };
00231 #endif
00232
00234
00235
00236 #ifdef STLSOFT_UNITTEST
00237 # include "./unittest/functionals_unittest_.h"
00238 #endif
00239
00240
00241
00242 #ifndef _STLSOFT_NO_NAMESPACE
00243 }
00244 #endif
00245
00246
00247
00248 #endif
00249
00250