Main Page | Modules | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

String.h

Go to the documentation of this file.
00001 /********************************************************************
00002 
00003 Copyright 2006, ACCESS Systems Americas, Inc. All rights reserved.
00004 
00005 The contents of this file are subject to the Mozilla Public License Version
00006 1.1 (the "License"); you may not use this file except in compliance with
00007 the License. You may obtain a copy of the License at
00008 http://www.mozilla.org/MPL/
00009 
00010 Software distributed under the License is distributed on an "AS IS" basis,
00011 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012 for the specific language governing rights and limitations under the
00013 License.
00014 
00015 The Original Code is the entire contents of this file.
00016 
00017 The Initial Developer of the Original Code is ACCESS Systems Americas, Inc.
00018 
00019 Portions created by ACCESS Systems Americas, Inc. are Copyright © 2006. All
00020 Rights Reserved.
00021 
00022 Contributor(s): none.
00023 
00024 ********************************************************************/
00025 /*
00026  * Copyright (c) 2005 Palmsource, Inc.
00027  *
00028  * This software is licensed as described in the file LICENSE, which
00029  * you should have received as part of this distribution. The terms
00030  * are also available at http://www.openbinder.org/license.html.
00031  *
00032  * This software consists of voluntary contributions made by many
00033  * individuals. For the exact contribution history, see the revision
00034  * history and logs, available at http://www.openbinder.org
00035  */
00036 
00037 #ifndef _SUPPORT_STRING_H
00038 #define _SUPPORT_STRING_H
00039 
00040 #include <string>
00041 
00042 namespace alp {
00043 
00044 class string : public std::string
00045 {
00046         public:
00047                                         string(const std::string& _other) : std::string(_other), utf8(*this) { ; }
00048                                         string(const char* _other, size_type _pos = 0, size_type _n = npos) : std::string(NULL == _other ? "" : _other, _pos, _n), utf8(*this) { ; }
00049                                         string(const char* _other, size_t _length) : std::string(NULL == _other ? "" : _other, _length), utf8(*this) { ; }
00050                                         string(const string& _other) : std::string(_other.c_str()), utf8(*this) { ; }
00051                                         string() : utf8(*this) { ; }
00052 
00053                         string& operator<<(const string& _other);
00054                         string& operator<<(const char* _other);
00055                         string& operator<<(uint32_t _val);
00056                         string& operator<<(int32_t _val);
00057                         string& operator<<(int64_t _val);
00058                         string& operator<<(uint64_t _val);
00059                         string& operator=(const string& _other) { std::string::operator=(_other); return *this; }
00060                         
00061         public:         
00062                         class utf8_impl
00063                         {
00064                                 public:
00065                                         utf8_impl(alp::string& _self) : fSelf(_self) { }
00066                                         
00067                                         size_t length() const;
00068                                         
00069                                 private:
00070                                         alp::string& fSelf;
00071                         };
00072                                         
00073         public:
00074                         utf8_impl       utf8;
00075 };
00076 
00077 // ------------------------------------------------------------------------
00078 inline size_t
00079 utf8_char_len(uint8_t ch)
00080 {
00081         return ((0xe5000000 >> ((ch >> 3) & 0x1e)) & 3) + 1;
00082 }
00083 
00084 // ------------------------------------------------------------------------
00085 inline uint32_t
00086 utf8_char_to_uint32(const uint8_t *src, uint32_t length)
00087 {
00088         uint32_t result = 0;
00089 
00090         for (uint32_t index = 0; index < length; index++)
00091                 result |= src[index] << (24 - index * 8);
00092 
00093         return result;
00094 }
00095 
00096 
00097 
00102 size_t uint32_to_utf8(uint32_t _source, uint8_t* _result);
00103 
00104 
00105 }       // namespace alp
00106 
00107 std::string& operator<<(std::string& _lhs, const std::string& _other);
00108 std::string& operator<<(std::string& _lhs, const char* _other);
00109 std::string& operator<<(std::string& _lhs, uint32_t _val);
00110 std::string& operator<<(std::string& _lhs, int32_t _val);
00111 
00112 
00113 #endif /* _SUPPORT_STRING_H */

Generated on Sat Dec 16 20:29:47 2006 for hiker-0.9 by  doxygen 1.4.4