vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
staticstring.h
Go to the documentation of this file.
1 #ifndef STATICSTRING_H_
2 #define STATICSTRING_H_
3 
4 #include <string>
5 #include <cstring>
6 #include "utils.h"
7 #include "longstring.h"
8 
9 namespace AP_LSystem {
14 {
15 public:
16  char * str;
17  int length;
18 
19  StaticString( const char * str, int length ):length(length)
20  {
21  this->str = new char[length];
22  memcpy( (void *) this->str, str, length);
23  }
24 
26  {
27  this->length = str->length();
28  this->str = new char[length];
29  memcpy( (void *) this->str, str->getData(), length);
30  }
31 
32  StaticString( char ch ):length(1)
33  {
34  this->str = new char[1];
35  this->str[0] = ch;
36  }
37 
38  StaticString( std::string str )
39  {
40  this->length = str.length();
41  this->str = new char[length];
42  memcpy( (void *) this->str, str.c_str(), length);
43  }
44 
46  {
47  this->length = c.length;
48  this->str = new char[this->length];
49  memcpy( (void *) this->str, c.str, this->length);
50  }
51 
53  {
54  this->length = c.length;
55  this->str = new char[this->length];
56  memcpy( (void *) this->str, c.str, this->length);
57 
58  return *this;
59  }
60 
61  std::string toString()
62  {
63  return std::string(this->str, this->length);
64  }
65 
67  {
68  if(str)
69  {
70  delete[] str;
71  }
72  }
73 };
74 }
75 
76 #endif