images/plugin_impl/string_impl.cpp

Go to the documentation of this file.
00001 /*
00002  * File Name: string_impl.cpp
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-images.
00007  *
00008  * uds-plugin-images is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-images is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 #include <cassert>
00028 #include "string_impl.h"
00029 
00030 namespace images
00031 {
00032 
00033 StringImpl::StringImpl()
00034 {
00035     assign = assign_impl;
00036     get_buffer = get_buffer_impl;
00037     size = size_impl;
00038 }
00039 
00040 StringImpl::StringImpl(const char *str)
00041 : impl(str)
00042 {
00043     assign = assign_impl;
00044     get_buffer = get_buffer_impl;
00045     size = size_impl;
00046 }
00047 
00048 StringImpl::StringImpl(const std::string& str)
00049 : impl(str)
00050 {
00051     assign = assign_impl;
00052     get_buffer = get_buffer_impl;
00053     size = size_impl;
00054 }
00055 
00056 StringImpl::StringImpl(const StringImpl &src)
00057 : impl(src.impl)
00058 {
00059     assign = assign_impl;
00060     get_buffer = get_buffer_impl;
00061     size = size_impl;
00062 }
00063 
00064 StringImpl::~StringImpl()
00065 {
00066 }
00067 
00068 StringImpl& StringImpl::operator = (const StringImpl &right)
00069 {
00070     if (this != &right)
00071     {
00072         impl = right.impl;
00073     }
00074     return *this;
00075 }
00076 
00077 bool StringImpl::operator == (const StringImpl &right)
00078 {
00079     return (impl == right.impl);
00080 }
00081 
00082 StringImpl * StringImpl::down_cast(_UDSString * ptr)
00083 {
00084     return static_cast<StringImpl *>(ptr);
00085 }
00086 
00087 const StringImpl * StringImpl::down_cast(const _UDSString * ptr)
00088 {
00089     return static_cast<const StringImpl *>(ptr);
00090 }
00091 
00092 _UDSString * StringImpl::assign_impl(_UDSString * thiz, 
00093                                      const char * src)
00094 {
00095     assert(thiz);
00096     StringImpl * object = down_cast(thiz);
00097     object->impl = src;
00098     return thiz;    
00099 }
00100 
00101 const char* StringImpl::get_buffer_impl(const _UDSString *thiz)
00102 {
00103     assert(thiz);
00104     const StringImpl * object = down_cast(thiz);
00105     return object->impl.c_str();
00106 }
00107 
00108 unsigned int StringImpl::size_impl(const _UDSString   *thiz)
00109 {
00110     assert(thiz);
00111     const StringImpl * object = down_cast(thiz);
00112     return static_cast<unsigned int>(object->impl.size());
00113 }
00114 
00115 };  // namespace images
00116 
00117 
Generated by  doxygen 1.6.2-20100208