media/omx-plugin/include/ics/utils/String16.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/omx-plugin/include/ics/utils/String16.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,238 @@
     1.4 +/*
     1.5 + * Copyright (C) 2005 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef ANDROID_STRING16_H
    1.21 +#define ANDROID_STRING16_H
    1.22 +
    1.23 +#include <utils/Errors.h>
    1.24 +#include <utils/SharedBuffer.h>
    1.25 +#include <utils/Unicode.h>
    1.26 +
    1.27 +// ---------------------------------------------------------------------------
    1.28 +
    1.29 +extern "C" {
    1.30 +
    1.31 +}
    1.32 +
    1.33 +// ---------------------------------------------------------------------------
    1.34 +
    1.35 +namespace android {
    1.36 +
    1.37 +// ---------------------------------------------------------------------------
    1.38 +
    1.39 +class String8;
    1.40 +class TextOutput;
    1.41 +
    1.42 +//! This is a string holding UTF-16 characters.
    1.43 +class String16
    1.44 +{
    1.45 +public:
    1.46 +                                String16();
    1.47 +                                String16(const String16& o);
    1.48 +                                String16(const String16& o,
    1.49 +                                         size_t len,
    1.50 +                                         size_t begin=0);
    1.51 +    explicit                    String16(const char16_t* o);
    1.52 +    explicit                    String16(const char16_t* o, size_t len);
    1.53 +    explicit                    String16(const String8& o);
    1.54 +    explicit                    String16(const char* o);
    1.55 +    explicit                    String16(const char* o, size_t len);
    1.56 +
    1.57 +                                ~String16();
    1.58 +    
    1.59 +    inline  const char16_t*     string() const;
    1.60 +    inline  size_t              size() const;
    1.61 +    
    1.62 +    inline  const SharedBuffer* sharedBuffer() const;
    1.63 +    
    1.64 +            void                setTo(const String16& other);
    1.65 +            status_t            setTo(const char16_t* other);
    1.66 +            status_t            setTo(const char16_t* other, size_t len);
    1.67 +            status_t            setTo(const String16& other,
    1.68 +                                      size_t len,
    1.69 +                                      size_t begin=0);
    1.70 +    
    1.71 +            status_t            append(const String16& other);
    1.72 +            status_t            append(const char16_t* other, size_t len);
    1.73 +            
    1.74 +    inline  String16&           operator=(const String16& other);
    1.75 +    
    1.76 +    inline  String16&           operator+=(const String16& other);
    1.77 +    inline  String16            operator+(const String16& other) const;
    1.78 +
    1.79 +            status_t            insert(size_t pos, const char16_t* chrs);
    1.80 +            status_t            insert(size_t pos,
    1.81 +                                       const char16_t* chrs, size_t len);
    1.82 +
    1.83 +            ssize_t             findFirst(char16_t c) const;
    1.84 +            ssize_t             findLast(char16_t c) const;
    1.85 +
    1.86 +            bool                startsWith(const String16& prefix) const;
    1.87 +            bool                startsWith(const char16_t* prefix) const;
    1.88 +            
    1.89 +            status_t            makeLower();
    1.90 +
    1.91 +            status_t            replaceAll(char16_t replaceThis,
    1.92 +                                           char16_t withThis);
    1.93 +
    1.94 +            status_t            remove(size_t len, size_t begin=0);
    1.95 +
    1.96 +    inline  int                 compare(const String16& other) const;
    1.97 +
    1.98 +    inline  bool                operator<(const String16& other) const;
    1.99 +    inline  bool                operator<=(const String16& other) const;
   1.100 +    inline  bool                operator==(const String16& other) const;
   1.101 +    inline  bool                operator!=(const String16& other) const;
   1.102 +    inline  bool                operator>=(const String16& other) const;
   1.103 +    inline  bool                operator>(const String16& other) const;
   1.104 +    
   1.105 +    inline  bool                operator<(const char16_t* other) const;
   1.106 +    inline  bool                operator<=(const char16_t* other) const;
   1.107 +    inline  bool                operator==(const char16_t* other) const;
   1.108 +    inline  bool                operator!=(const char16_t* other) const;
   1.109 +    inline  bool                operator>=(const char16_t* other) const;
   1.110 +    inline  bool                operator>(const char16_t* other) const;
   1.111 +    
   1.112 +    inline                      operator const char16_t*() const;
   1.113 +    
   1.114 +private:
   1.115 +            const char16_t*     mString;
   1.116 +};
   1.117 +
   1.118 +TextOutput& operator<<(TextOutput& to, const String16& val);
   1.119 +
   1.120 +// ---------------------------------------------------------------------------
   1.121 +// No user servicable parts below.
   1.122 +
   1.123 +inline int compare_type(const String16& lhs, const String16& rhs)
   1.124 +{
   1.125 +    return lhs.compare(rhs);
   1.126 +}
   1.127 +
   1.128 +inline int strictly_order_type(const String16& lhs, const String16& rhs)
   1.129 +{
   1.130 +    return compare_type(lhs, rhs) < 0;
   1.131 +}
   1.132 +
   1.133 +inline const char16_t* String16::string() const
   1.134 +{
   1.135 +    return mString;
   1.136 +}
   1.137 +
   1.138 +inline size_t String16::size() const
   1.139 +{
   1.140 +    return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1;
   1.141 +}
   1.142 +
   1.143 +inline const SharedBuffer* String16::sharedBuffer() const
   1.144 +{
   1.145 +    return SharedBuffer::bufferFromData(mString);
   1.146 +}
   1.147 +
   1.148 +inline String16& String16::operator=(const String16& other)
   1.149 +{
   1.150 +    setTo(other);
   1.151 +    return *this;
   1.152 +}
   1.153 +
   1.154 +inline String16& String16::operator+=(const String16& other)
   1.155 +{
   1.156 +    append(other);
   1.157 +    return *this;
   1.158 +}
   1.159 +
   1.160 +inline String16 String16::operator+(const String16& other) const
   1.161 +{
   1.162 +    String16 tmp(*this);
   1.163 +    tmp += other;
   1.164 +    return tmp;
   1.165 +}
   1.166 +
   1.167 +inline int String16::compare(const String16& other) const
   1.168 +{
   1.169 +    return strzcmp16(mString, size(), other.mString, other.size());
   1.170 +}
   1.171 +
   1.172 +inline bool String16::operator<(const String16& other) const
   1.173 +{
   1.174 +    return strzcmp16(mString, size(), other.mString, other.size()) < 0;
   1.175 +}
   1.176 +
   1.177 +inline bool String16::operator<=(const String16& other) const
   1.178 +{
   1.179 +    return strzcmp16(mString, size(), other.mString, other.size()) <= 0;
   1.180 +}
   1.181 +
   1.182 +inline bool String16::operator==(const String16& other) const
   1.183 +{
   1.184 +    return strzcmp16(mString, size(), other.mString, other.size()) == 0;
   1.185 +}
   1.186 +
   1.187 +inline bool String16::operator!=(const String16& other) const
   1.188 +{
   1.189 +    return strzcmp16(mString, size(), other.mString, other.size()) != 0;
   1.190 +}
   1.191 +
   1.192 +inline bool String16::operator>=(const String16& other) const
   1.193 +{
   1.194 +    return strzcmp16(mString, size(), other.mString, other.size()) >= 0;
   1.195 +}
   1.196 +
   1.197 +inline bool String16::operator>(const String16& other) const
   1.198 +{
   1.199 +    return strzcmp16(mString, size(), other.mString, other.size()) > 0;
   1.200 +}
   1.201 +
   1.202 +inline bool String16::operator<(const char16_t* other) const
   1.203 +{
   1.204 +    return strcmp16(mString, other) < 0;
   1.205 +}
   1.206 +
   1.207 +inline bool String16::operator<=(const char16_t* other) const
   1.208 +{
   1.209 +    return strcmp16(mString, other) <= 0;
   1.210 +}
   1.211 +
   1.212 +inline bool String16::operator==(const char16_t* other) const
   1.213 +{
   1.214 +    return strcmp16(mString, other) == 0;
   1.215 +}
   1.216 +
   1.217 +inline bool String16::operator!=(const char16_t* other) const
   1.218 +{
   1.219 +    return strcmp16(mString, other) != 0;
   1.220 +}
   1.221 +
   1.222 +inline bool String16::operator>=(const char16_t* other) const
   1.223 +{
   1.224 +    return strcmp16(mString, other) >= 0;
   1.225 +}
   1.226 +
   1.227 +inline bool String16::operator>(const char16_t* other) const
   1.228 +{
   1.229 +    return strcmp16(mString, other) > 0;
   1.230 +}
   1.231 +
   1.232 +inline String16::operator const char16_t*() const
   1.233 +{
   1.234 +    return mString;
   1.235 +}
   1.236 +
   1.237 +}; // namespace android
   1.238 +
   1.239 +// ---------------------------------------------------------------------------
   1.240 +
   1.241 +#endif // ANDROID_STRING16_H

mercurial