This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 30th, 2012  |  syntax: C++  |  size: 0.74 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include "CFString.h"
  2. char* CFString::strempty = "";
  3. CFString::CFString()    {
  4.         strdata = strempty;
  5. }
  6.  
  7. CFString::CFString(const char* str)     {
  8.         strdata = NULL;
  9.         if (str != NULL)        {
  10.                 strdata = new char[strlen(str) + 1];
  11.                 strncpy(strdata, str, strlen(str));
  12.                 strdata[strlen(strdata)] = 0;
  13.         } else strdata = strempty;
  14. }
  15.  
  16. CFString::CFString(const CFString& str) {
  17.         if(str.strdata != NULL) {
  18.                 strdata = new char[strlen(str) + 1];
  19.                 strncpy(strdata, str.strdata, strlen(strdata));
  20.                 strdata[strlen(strdata)] = 0;
  21.         } else strdata = strempty;
  22. }
  23.  
  24. CFString::~CFString()   {
  25.         if (strdata != NULL){
  26.                 delete[] strdata;
  27.         }
  28. }
  29. CFString::operator const char* ()
  30. {
  31.         return strdata;
  32. }
  33.  
  34. CFString::operator const char* () const
  35. {
  36.         return strdata;
  37. }
clone this paste RAW Paste Data