- sof_8070.zip
- sof
- console
- sof_console.vcproj
- src
- doc
- doxygen
- Doxyfile
- website
- diagrams
- presentations
- sof_overview.png
- sof_overview_small.png
- sequence_charts
- creating_bundles.sqd
- registering_services.sqd
- images
- creating_bundles.gif
- registering_services.sqd.jpg
- sof_console.gif
- soflogo.png
- sof.html
- examples
- bundle1
- sof_examples_bundle1.vcproj
- src
- bundle2
- sof_examples_bundle2.vcproj
- src
- common
- src
- sof_examples.vcproj
- src
- extern
- CppUnitLite
- CppUnitLite.vcproj
- src
- impl
- sof.sln
- sof.vcproj
- src
- sof
- config
- framework
- instantiation
- services
- admin
- util
- test
- bin
- config_file_reader_test.sof
- test_config_file.sof
- sof_test.vcproj
- src
- TestDll1
- src
- TestDll1.vcproj
- TestDll2
- src
- TestDll2.vcproj
|
#include "SimpleString.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
static const int DEFAULT_SIZE = 20;
SimpleString::SimpleString ()
: buffer(new char [1])
{
buffer [0] = '\0';
}
SimpleString::SimpleString (const char *otherBuffer)
: buffer (new char [strlen (otherBuffer) + 1])
{
strcpy (buffer, otherBuffer);
}
SimpleString::SimpleString (const SimpleString& other)
{
buffer = new char [other.size() + 1];
strcpy(buffer, other.buffer);
}
SimpleString SimpleString::operator= (const SimpleString& other)
{
delete buffer;
buffer = new char [other.size() + 1];
strcpy(buffer, other.buffer);
return *this;
}
char *SimpleString::asCharString () const
{
return buffer;
}
int SimpleString::size() const
{
return strlen (buffer);
}
SimpleString::~SimpleString ()
{
delete [] buffer;
}
bool operator== (const SimpleString& left, const SimpleString& right)
{
return !strcmp (left.asCharString (), right.asCharString ());
}
SimpleString StringFrom (bool value)
{
char buffer [sizeof ("false") + 1];
sprintf (buffer, "%s", value ? "true" : "false");
return SimpleString(buffer);
}
SimpleString StringFrom (const char *value)
{
return SimpleString(value);
}
SimpleString StringFrom (long value)
{
char buffer [DEFAULT_SIZE];
sprintf (buffer, "%ld", value);
return SimpleString(buffer);
}
SimpleString StringFrom (double value)
{
char buffer [DEFAULT_SIZE];
sprintf (buffer, "%lf", value);
return SimpleString(buffer);
}
SimpleString StringFrom (const SimpleString& value)
{
return SimpleString(value);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.