Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
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)
 

Static Public Member Functions

static const char * CloneCString (const char *a_c_string)
 

Detailed Description

Definition at line 41 of file sample2.h.

Constructor & Destructor Documentation

◆ MyString() [1/3]

MyString::MyString ( )
inline

Definition at line 55 of file sample2.h.

55: c_string_(NULL) {}

◆ MyString() [2/3]

MyString::MyString ( const char * a_c_string)
inlineexplicit

Definition at line 58 of file sample2.h.

58 : c_string_(NULL) {
59 Set(a_c_string);
60 }
void Set(const char *c_string)
Definition sample2.cc:51
Here is the call graph for this function:

◆ MyString() [3/3]

MyString::MyString ( const MyString & string)
inline

Definition at line 63 of file sample2.h.

63 : c_string_(NULL) {
64 Set(string.c_string_);
65 }
Here is the call graph for this function:

◆ ~MyString()

MyString::~MyString ( )
inline

Definition at line 71 of file sample2.h.

71{ delete[] c_string_; }

Member Function Documentation

◆ c_string()

const char * MyString::c_string ( ) const
inline

Definition at line 74 of file sample2.h.

74{ return c_string_; }

◆ CloneCString()

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

Definition at line 39 of file sample2.cc.

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}
size_t len
memcpy((char *) pInfo->slotDescription, s, l)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Length()

size_t MyString::Length ( ) const
inline

Definition at line 76 of file sample2.h.

76 {
77 return c_string_ == NULL ? 0 : strlen(c_string_);
78 }

◆ Set()

void MyString::Set ( const char * c_string)

Definition at line 51 of file sample2.cc.

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}
static const char * CloneCString(const char *a_c_string)
Definition sample2.cc:39
Here is the call graph for this function:
Here is the caller graph for this function:

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