os/ossrv/ossrv_pub/boost_apis/boost/python/str.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/str.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,414 @@
     1.4 +// Copyright David Abrahams 2002.
     1.5 +// Distributed under the Boost Software License, Version 1.0. (See
     1.6 +// accompanying file LICENSE_1_0.txt or copy at
     1.7 +// http://www.boost.org/LICENSE_1_0.txt)
     1.8 +#ifndef STR_20020703_HPP
     1.9 +#define STR_20020703_HPP
    1.10 +
    1.11 +# include <boost/python/detail/prefix.hpp>
    1.12 +
    1.13 +#include <boost/python/object.hpp>
    1.14 +#include <boost/python/list.hpp>
    1.15 +#include <boost/python/converter/pytype_object_mgr_traits.hpp>
    1.16 +
    1.17 +// disable defines in <cctype> provided by some system libraries
    1.18 +#undef isspace
    1.19 +#undef islower
    1.20 +#undef isalpha
    1.21 +#undef isdigit
    1.22 +#undef isalnum
    1.23 +#undef isupper
    1.24 +
    1.25 +namespace boost { namespace python {
    1.26 +
    1.27 +class str;
    1.28 +
    1.29 +namespace detail
    1.30 +{
    1.31 +  struct BOOST_PYTHON_DECL str_base : object
    1.32 +  {
    1.33 +      str capitalize() const;
    1.34 +
    1.35 +      str center(object_cref width) const;
    1.36 +
    1.37 +      long count(object_cref sub) const;
    1.38 +
    1.39 +      long count(object_cref sub, object_cref start) const;
    1.40 +    
    1.41 +      long count(object_cref sub, object_cref start, object_cref end) const;
    1.42 +
    1.43 +      object decode() const;
    1.44 +      object decode(object_cref encoding) const;
    1.45 +
    1.46 +      object decode(object_cref encoding, object_cref errors) const;
    1.47 +
    1.48 +      object encode() const;
    1.49 +      object encode(object_cref encoding) const;
    1.50 +      object encode(object_cref encoding, object_cref errors) const;
    1.51 +
    1.52 +      bool endswith(object_cref suffix) const;
    1.53 +    
    1.54 +      bool endswith(object_cref suffix, object_cref start) const;
    1.55 +      bool endswith(object_cref suffix, object_cref start, object_cref end) const;
    1.56 +    
    1.57 +      str expandtabs() const;
    1.58 +      str expandtabs(object_cref tabsize) const;
    1.59 +
    1.60 +      long find(object_cref sub) const;
    1.61 +      long find(object_cref sub, object_cref start) const;
    1.62 +
    1.63 +      long find(object_cref sub, object_cref start, object_cref end) const;
    1.64 +
    1.65 +      long index(object_cref sub) const;
    1.66 +
    1.67 +      long index(object_cref sub, object_cref start) const;
    1.68 +      long index(object_cref sub, object_cref start, object_cref end) const;
    1.69 +
    1.70 +      bool isalnum() const;
    1.71 +      bool isalpha() const;
    1.72 +      bool isdigit() const;
    1.73 +      bool islower() const;
    1.74 +      bool isspace() const;
    1.75 +      bool istitle() const;
    1.76 +      bool isupper() const;
    1.77 +    
    1.78 +      str join(object_cref sequence) const;
    1.79 +
    1.80 +      str ljust(object_cref width) const;
    1.81 +      str lower() const;
    1.82 +      str lstrip() const;
    1.83 +
    1.84 +      str replace(object_cref old, object_cref new_) const;
    1.85 +      str replace(object_cref old, object_cref new_, object_cref maxsplit) const;
    1.86 +      long rfind(object_cref sub) const;
    1.87 +
    1.88 +      long rfind(object_cref sub, object_cref start) const;
    1.89 +
    1.90 +      long rfind(object_cref sub, object_cref start, object_cref end) const;
    1.91 +      long rindex(object_cref sub) const;
    1.92 +      long rindex(object_cref sub, object_cref start) const;
    1.93 +
    1.94 +
    1.95 +      long rindex(object_cref sub, object_cref start, object_cref end) const;
    1.96 +
    1.97 +      str rjust(object_cref width) const;
    1.98 +    
    1.99 +      str rstrip() const;
   1.100 +    
   1.101 +      list split() const; 
   1.102 +      list split(object_cref sep) const;
   1.103 +   
   1.104 +      list split(object_cref sep, object_cref maxsplit) const; 
   1.105 +    
   1.106 +
   1.107 +      list splitlines() const;
   1.108 +      list splitlines(object_cref keepends) const;
   1.109 +
   1.110 +      bool startswith(object_cref prefix) const;
   1.111 +
   1.112 +
   1.113 +      bool startswith(object_cref prefix, object_cref start) const;
   1.114 +      bool startswith(object_cref prefix, object_cref start, object_cref end) const;
   1.115 +
   1.116 +      str strip() const;
   1.117 +      str swapcase() const;
   1.118 +      str title() const;
   1.119 +    
   1.120 +      str translate(object_cref table) const;
   1.121 +
   1.122 +      str translate(object_cref table, object_cref deletechars) const;
   1.123 +
   1.124 +    
   1.125 +      str upper() const;
   1.126 +
   1.127 +   protected:
   1.128 +      str_base(); // new str
   1.129 +    
   1.130 +      str_base(const char* s); // new str
   1.131 +
   1.132 +      str_base(char const* start, char const* finish);
   1.133 +      
   1.134 +      str_base(char const* start, std::size_t length);
   1.135 +      
   1.136 +      explicit str_base(object_cref other);
   1.137 +
   1.138 +      BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(str_base, object)
   1.139 +   private:
   1.140 +      static new_reference call(object const&);
   1.141 +  };
   1.142 +}
   1.143 +
   1.144 +
   1.145 +class str : public detail::str_base
   1.146 +{
   1.147 +    typedef detail::str_base base;
   1.148 + public:
   1.149 +    str() {} // new str
   1.150 +    
   1.151 +    str(const char* s) : base(s) {} // new str
   1.152 +    
   1.153 +    str(char const* start, char const* finish) // new str
   1.154 +      : base(start, finish)
   1.155 +    {}
   1.156 +    
   1.157 +    str(char const* start, std::size_t length) // new str
   1.158 +      : base(start, length)
   1.159 +    {}
   1.160 +    
   1.161 +    template <class T>
   1.162 +    explicit str(T const& other)
   1.163 +        : base(object(other))
   1.164 +    {
   1.165 +    }
   1.166 +
   1.167 +    template <class T>
   1.168 +    str center(T const& width) const
   1.169 +    {
   1.170 +        return base::center(object(width));
   1.171 +    }
   1.172 +
   1.173 +    template<class T>
   1.174 +    long count(T const& sub) const
   1.175 +    {
   1.176 +        return base::count(object(sub));
   1.177 +    }
   1.178 +
   1.179 +    template<class T1, class T2>
   1.180 +    long count(T1 const& sub,T2 const& start) const
   1.181 +    {
   1.182 +        return base::count(object(sub), object(start));
   1.183 +    }
   1.184 +
   1.185 +    template<class T1, class T2, class T3>
   1.186 +    long count(T1 const& sub,T2 const& start, T3 const& end) const
   1.187 +    {
   1.188 +        return base::count(object(sub), object(start));
   1.189 +    }
   1.190 +
   1.191 +    object decode() const { return base::decode(); }
   1.192 +    
   1.193 +    template<class T>
   1.194 +    object decode(T const& encoding) const
   1.195 +    {
   1.196 +        return base::decode(object(encoding));
   1.197 +    }
   1.198 +
   1.199 +    template<class T1, class T2>
   1.200 +    object decode(T1 const& encoding, T2 const& errors) const
   1.201 +    {
   1.202 +        return base::decode(object(encoding),object(errors));
   1.203 +    }
   1.204 +
   1.205 +    object encode() const { return base::encode(); }
   1.206 +
   1.207 +    template <class T>
   1.208 +    object encode(T const& encoding) const
   1.209 +    {
   1.210 +        return base::encode(object(encoding));
   1.211 +    }
   1.212 +
   1.213 +    template <class T1, class T2>
   1.214 +    object encode(T1 const& encoding, T2 const& errors) const
   1.215 +    {
   1.216 +        return base::encode(object(encoding),object(errors));
   1.217 +    }
   1.218 +
   1.219 +    template <class T>
   1.220 +    bool endswith(T const& suffix) const
   1.221 +    {
   1.222 +        return base::endswith(object(suffix));
   1.223 +    }
   1.224 +
   1.225 +    template <class T1, class T2>
   1.226 +    bool endswith(T1 const& suffix, T2 const& start) const
   1.227 +    {
   1.228 +        return base::endswith(object(suffix), object(start));
   1.229 +    }
   1.230 +
   1.231 +    template <class T1, class T2, class T3>
   1.232 +    bool endswith(T1 const& suffix, T2 const& start, T3 const& end) const
   1.233 +    {
   1.234 +        return base::endswith(object(suffix), object(start), object(end));
   1.235 +    }
   1.236 +    
   1.237 +    str expandtabs() const { return base::expandtabs(); }
   1.238 +
   1.239 +    template <class T>
   1.240 +    str expandtabs(T const& tabsize) const
   1.241 +    {
   1.242 +        return base::expandtabs(object(tabsize));
   1.243 +    }
   1.244 +    
   1.245 +    template <class T>
   1.246 +    long find(T const& sub) const
   1.247 +    {
   1.248 +        return base::find(object(sub));
   1.249 +    }
   1.250 +
   1.251 +    template <class T1, class T2>
   1.252 +    long find(T1 const& sub, T2 const& start) const
   1.253 +    {
   1.254 +        return base::find(object(sub), object(start));
   1.255 +    }
   1.256 +
   1.257 +    template <class T1, class T2, class T3>
   1.258 +    long find(T1 const& sub, T2 const& start, T3 const& end) const
   1.259 +    {
   1.260 +        return base::find(object(sub), object(start), object(end));
   1.261 +    }
   1.262 +    
   1.263 +    template <class T>
   1.264 +    long index(T const& sub) const
   1.265 +    {
   1.266 +        return base::index(object(sub));
   1.267 +    }
   1.268 +    
   1.269 +    template <class T1, class T2>
   1.270 +    long index(T1 const& sub, T2 const& start) const
   1.271 +    {
   1.272 +        return base::index(object(sub), object(start));
   1.273 +    }
   1.274 +
   1.275 +    template <class T1, class T2, class T3>
   1.276 +    long index(T1 const& sub, T2 const& start, T3 const& end) const
   1.277 +    {
   1.278 +        return base::index(object(sub), object(start), object(end));
   1.279 +    }
   1.280 +
   1.281 +    template <class T>
   1.282 +    str join(T const& sequence) const
   1.283 +    {
   1.284 +        return base::join(object(sequence));
   1.285 +    }
   1.286 +    
   1.287 +    template <class T>
   1.288 +    str ljust(T const& width) const
   1.289 +    {
   1.290 +        return base::ljust(object(width));
   1.291 +    }
   1.292 +
   1.293 +    template <class T1, class T2>
   1.294 +    str replace(T1 const& old, T2 const& new_) const 
   1.295 +    {
   1.296 +        return base::replace(object(old),object(new_));
   1.297 +    }
   1.298 +
   1.299 +    template <class T1, class T2, class T3>
   1.300 +    str replace(T1 const& old, T2 const& new_, T3 const& maxsplit) const 
   1.301 +    {
   1.302 +        return base::replace(object(old),object(new_), object(maxsplit));
   1.303 +    }
   1.304 +    
   1.305 +    template <class T>
   1.306 +    long rfind(T const& sub) const
   1.307 +    {
   1.308 +        return base::rfind(object(sub));
   1.309 +    }
   1.310 +
   1.311 +    template <class T1, class T2>
   1.312 +    long rfind(T1 const& sub, T2 const& start) const
   1.313 +    {
   1.314 +        return base::rfind(object(sub), object(start));
   1.315 +    }
   1.316 +    
   1.317 +    template <class T1, class T2, class T3>
   1.318 +    long rfind(T1 const& sub, T2 const& start, T3 const& end) const
   1.319 +    {
   1.320 +        return base::rfind(object(sub), object(start), object(end));
   1.321 +    }
   1.322 +    
   1.323 +    template <class T>
   1.324 +    long rindex(T const& sub) const
   1.325 +    {
   1.326 +        return base::rindex(object(sub));
   1.327 +    }
   1.328 +
   1.329 +    template <class T1, class T2>
   1.330 +    long rindex(T1 const& sub, T2 const& start) const
   1.331 +    {
   1.332 +        return base::rindex(object(sub), object(start));
   1.333 +    }
   1.334 +
   1.335 +    template <class T1, class T2, class T3>
   1.336 +    long rindex(T1 const& sub, T2 const& start, T3 const& end) const
   1.337 +    {
   1.338 +        return base::rindex(object(sub), object(start), object(end));
   1.339 +    }
   1.340 +
   1.341 +    template <class T>
   1.342 +    str rjust(T const& width) const
   1.343 +    {
   1.344 +        return base::rjust(object(width));
   1.345 +    }
   1.346 +    
   1.347 +    list split() const { return base::split(); }
   1.348 +   
   1.349 +    template <class T>
   1.350 +    list split(T const& sep) const
   1.351 +    {
   1.352 +        return base::split(object(sep));
   1.353 +    }
   1.354 +
   1.355 +    template <class T1, class T2>
   1.356 +    list split(T1 const& sep, T2 const& maxsplit) const
   1.357 +    {
   1.358 +        return base::split(object(sep), object(maxsplit));
   1.359 +    }
   1.360 +
   1.361 +    list splitlines() const { return base::splitlines(); }
   1.362 +
   1.363 +    template <class T>
   1.364 +    list splitlines(T const& keepends) const
   1.365 +    {
   1.366 +        return base::splitlines(object(keepends));
   1.367 +    }
   1.368 +
   1.369 +    template <class T>
   1.370 +    bool startswith(T const& prefix) const
   1.371 +    {
   1.372 +        return base::startswith(object(prefix));
   1.373 +    }
   1.374 +
   1.375 +    template <class T1, class T2>
   1.376 +    bool startswith(T1 const& prefix, T2 const& start) const
   1.377 +    {
   1.378 +        return base::startswith(object(prefix), object(start));
   1.379 +    }
   1.380 +     
   1.381 +    template <class T1, class T2, class T3>
   1.382 +    bool startswith(T1 const& prefix, T2 const& start, T3 const& end) const
   1.383 +    {
   1.384 +        return base::startswith(object(prefix), object(start), object(end));
   1.385 +    }
   1.386 +
   1.387 +    template <class T>
   1.388 +    str translate(T const& table) const
   1.389 +    {
   1.390 +        return base::translate(object(table));
   1.391 +    }
   1.392 +
   1.393 +    template <class T1, class T2>
   1.394 +    str translate(T1 const& table, T2 const& deletechars) const
   1.395 +    {
   1.396 +        return base::translate(object(table), object(deletechars));
   1.397 +    }
   1.398 +    
   1.399 + public: // implementation detail -- for internal use only
   1.400 +    BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(str, base)
   1.401 +};
   1.402 +
   1.403 +//
   1.404 +// Converter Specializations
   1.405 +//
   1.406 +namespace converter
   1.407 +{
   1.408 +  template <>
   1.409 +  struct object_manager_traits<str>
   1.410 +      : pytype_object_manager_traits<&PyString_Type,str>
   1.411 +  {
   1.412 +  };
   1.413 +}
   1.414 +
   1.415 +}}  // namespace boost::python
   1.416 +
   1.417 +#endif // STR_20020703_HPP