OpenCL C++ Wrapper API 1.1
 All Classes Namespaces Files Functions Variables Typedefs Defines
Public Member Functions | Private Attributes
cl::string Class Reference

Simple string class, that provides a limited subset of std::string functionality but avoids many of the issues that come with that class. More...

#include <cl.hpp>

List of all members.

Public Member Functions

 string (void)
 string (char *str,::size_t size)
 string (char *str)
stringoperator= (const string &rhs)
 string (const string &rhs)
 ~string ()
::size_t size (void) const
::size_t length (void) const
const char * c_str (void) const

Private Attributes

::size_t size_
char * str_

Detailed Description

Simple string class, that provides a limited subset of std::string functionality but avoids many of the issues that come with that class.

Definition at line 345 of file cl.hpp.


Constructor & Destructor Documentation

cl::string::string ( void  ) [inline]

Definition at line 351 of file cl.hpp.

                 : size_(0), str_(NULL)
    {
    }
cl::string::string ( char *  str,
::size_t  size 
) [inline]

Definition at line 355 of file cl.hpp.

                                    :
        size_(size),
        str_(NULL)
    {
        str_ = new char[size_+1];
        if (str_ != NULL) {
            memcpy(str_, str, size_  * sizeof(char));
            str_[size_] = '\0';
        }
        else {
            size_ = 0;
        }
    }
cl::string::string ( char *  str) [inline]

Definition at line 369 of file cl.hpp.

                       :
        str_(NULL)
    {
        size_= ::strlen(str);
        str_ = new char[size_ + 1];
        if (str_ != NULL) {
            memcpy(str_, str, (size_ + 1) * sizeof(char));
        }
        else {
            size_ = 0;
        }
    }
cl::string::string ( const string rhs) [inline]

Definition at line 406 of file cl.hpp.

    {
        *this = rhs;
    }
cl::string::~string ( ) [inline]

Definition at line 411 of file cl.hpp.

    {
        if (str_ != NULL) {
            delete[] str_;
        }
    }

Member Function Documentation

const char* cl::string::c_str ( void  ) const [inline]

Definition at line 421 of file cl.hpp.

{ return (str_) ? str_ : "";}
::size_t cl::string::length ( void  ) const [inline]

Definition at line 419 of file cl.hpp.

{ return size(); }
string& cl::string::operator= ( const string rhs) [inline]

Definition at line 382 of file cl.hpp.

    {
        if (this == &rhs) {
            return *this;
        }

        if (rhs.size_ == 0 || rhs.str_ == NULL) {
            size_ = 0;
            str_  = NULL;
        } 
        else {
            size_ = rhs.size_;
            str_ = new char[size_ + 1];
            if (str_ != NULL) {
                memcpy(str_, rhs.str_, (size_ + 1) * sizeof(char));
            }
            else {
                size_ = 0;
            }
        }

        return *this;
    }
::size_t cl::string::size ( void  ) const [inline]

Definition at line 418 of file cl.hpp.

{ return size_; }

Member Data Documentation

Definition at line 348 of file cl.hpp.

char* cl::string::str_ [private]

Definition at line 349 of file cl.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Defines