proxygen
MyString Class Reference

#include <sample2.h>

Public Member Functions

 MyString ()
 
 MyString (const char *a_c_string)
 
 MyString (const MyString &string)
 
 ~MyString ()
 
const char * c_string () const
 
size_t Length () const
 
void Set (const char *c_string)
 
 MyString ()
 
 MyString (const char *a_c_string)
 
 MyString (const MyString &string)
 
 ~MyString ()
 
const char * c_string () const
 
size_t Length () const
 
void Set (const char *c_string)
 
 MyString ()
 
 MyString (const char *a_c_string)
 
 MyString (const MyString &string)
 
 ~MyString ()
 
const char * c_string () const
 
size_t Length () const
 
void Set (const char *c_string)
 

Static Public Member Functions

static const char * CloneCString (const char *a_c_string)
 
static const char * CloneCString (const char *a_c_string)
 
static const char * CloneCString (const char *a_c_string)
 

Private Member Functions

const MyStringoperator= (const MyString &rhs)
 
const MyStringoperator= (const MyString &rhs)
 
const MyStringoperator= (const MyString &rhs)
 

Private Attributes

const char * c_string_
 

Detailed Description

Definition at line 41 of file sample2.h.

Constructor & Destructor Documentation

MyString::MyString ( )
inline

Definition at line 55 of file sample2.h.

55 : c_string_(NULL) {}
const char * c_string_
Definition: sample2.h:43
MyString::MyString ( const char *  a_c_string)
inlineexplicit

Definition at line 58 of file sample2.h.

References Set().

58  : c_string_(NULL) {
59  Set(a_c_string);
60  }
const char * c_string_
Definition: sample2.h:43
void Set(const char *c_string)
Definition: sample2.cc:51
MyString::MyString ( const MyString string)
inline

Definition at line 63 of file sample2.h.

References Set().

63  : c_string_(NULL) {
64  Set(string.c_string_);
65  }
const char * c_string_
Definition: sample2.h:43
void Set(const char *c_string)
Definition: sample2.cc:51
MyString::~MyString ( )
inline

Definition at line 71 of file sample2.h.

References c_string_.

71 { delete[] c_string_; }
const char * c_string_
Definition: sample2.h:43
MyString::MyString ( )
inline

Definition at line 55 of file sample2.h.

55 : c_string_(NULL) {}
const char * c_string_
Definition: sample2.h:43
MyString::MyString ( const char *  a_c_string)
inlineexplicit

Definition at line 58 of file sample2.h.

References Set().

58  : c_string_(NULL) {
59  Set(a_c_string);
60  }
const char * c_string_
Definition: sample2.h:43
void Set(const char *c_string)
Definition: sample2.cc:51
MyString::MyString ( const MyString string)
inline

Definition at line 63 of file sample2.h.

References Set().

63  : c_string_(NULL) {
64  Set(string.c_string_);
65  }
const char * c_string_
Definition: sample2.h:43
void Set(const char *c_string)
Definition: sample2.cc:51
MyString::~MyString ( )
inline

Definition at line 71 of file sample2.h.

References c_string_.

71 { delete[] c_string_; }
const char * c_string_
Definition: sample2.h:43
MyString::MyString ( )
inline

Definition at line 55 of file sample2.h.

55 : c_string_(NULL) {}
const char * c_string_
Definition: sample2.h:43
MyString::MyString ( const char *  a_c_string)
inlineexplicit

Definition at line 58 of file sample2.h.

References Set().

58  : c_string_(NULL) {
59  Set(a_c_string);
60  }
const char * c_string_
Definition: sample2.h:43
void Set(const char *c_string)
Definition: sample2.cc:51
MyString::MyString ( const MyString string)
inline

Definition at line 63 of file sample2.h.

References Set().

63  : c_string_(NULL) {
64  Set(string.c_string_);
65  }
const char * c_string_
Definition: sample2.h:43
void Set(const char *c_string)
Definition: sample2.cc:51
MyString::~MyString ( )
inline

Definition at line 71 of file sample2.h.

References c_string_.

71 { delete[] c_string_; }
const char * c_string_
Definition: sample2.h:43

Member Function Documentation

const char* MyString::c_string ( ) const
inline

Definition at line 74 of file sample2.h.

References c_string_.

Referenced by Length(), and TEST().

74 { return c_string_; }
const char * c_string_
Definition: sample2.h:43
const char* MyString::c_string ( ) const
inline

Definition at line 74 of file sample2.h.

References c_string_.

74 { return c_string_; }
const char * c_string_
Definition: sample2.h:43
const char* MyString::c_string ( ) const
inline

Definition at line 74 of file sample2.h.

References c_string_.

74 { return c_string_; }
const char * c_string_
Definition: sample2.h:43
const char * MyString::CloneCString ( const char *  a_c_string)
static

Definition at line 39 of file sample2.cc.

Referenced by Set().

39  {
40  if (a_c_string == NULL) return NULL;
41 
42  const size_t len = strlen(a_c_string);
43  char* const clone = new char[ len + 1 ];
44  memcpy(clone, a_c_string, len + 1);
45 
46  return clone;
47 }
static const char* MyString::CloneCString ( const char *  a_c_string)
static
static const char* MyString::CloneCString ( const char *  a_c_string)
static
size_t MyString::Length ( ) const
inline

Definition at line 76 of file sample2.h.

References c_string(), and Set().

Referenced by TEST().

76  {
77  return c_string_ == NULL ? 0 : strlen(c_string_);
78  }
const char * c_string_
Definition: sample2.h:43
size_t MyString::Length ( ) const
inline

Definition at line 76 of file sample2.h.

References c_string(), and Set().

76  {
77  return c_string_ == NULL ? 0 : strlen(c_string_);
78  }
const char * c_string_
Definition: sample2.h:43
size_t MyString::Length ( ) const
inline

Definition at line 76 of file sample2.h.

References c_string(), and Set().

76  {
77  return c_string_ == NULL ? 0 : strlen(c_string_);
78  }
const char * c_string_
Definition: sample2.h:43
const MyString& MyString::operator= ( const MyString rhs)
private
const MyString& MyString::operator= ( const MyString rhs)
private
const MyString& MyString::operator= ( const MyString rhs)
private
void MyString::Set ( const char *  c_string)
void MyString::Set ( const char *  c_string)
void MyString::Set ( const char *  c_string)

Definition at line 51 of file sample2.cc.

References c_string_, CloneCString(), and shell_builder::temp.

Referenced by Length(), MyString(), and TEST().

51  {
52  // Makes sure this works when c_string == c_string_
53  const char* const temp = MyString::CloneCString(a_c_string);
54  delete[] c_string_;
55  c_string_ = temp;
56 }
const char * c_string_
Definition: sample2.h:43
static const char * CloneCString(const char *a_c_string)
Definition: sample2.cc:39

Member Data Documentation

const char * MyString::c_string_
private

Definition at line 43 of file sample2.h.

Referenced by c_string(), Set(), and ~MyString().


The documentation for this class was generated from the following files: