summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-10 13:29:20 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-10 13:29:20 +0100
commit82a5924c4e6d6ac72e31367506233d94b74b63e4 (patch)
tree8ba64841381470c77e143c3ef56fe72104f2a333
parent3ad07986ff0da5e195da030612b6253fbd12f57f (diff)
downloadsencha-lang-82a5924c4e6d6ac72e31367506233d94b74b63e4.tar.gz
sencha-lang-82a5924c4e6d6ac72e31367506233d94b74b63e4.tar.bz2
sencha-lang-82a5924c4e6d6ac72e31367506233d94b74b63e4.zip
Begginnig of arrays. First arrayification on strings.
-rw-r--r--Sencha-lang/Elements/SenchaArray.cpp48
-rw-r--r--Sencha-lang/Elements/SenchaArray.h30
2 files changed, 78 insertions, 0 deletions
diff --git a/Sencha-lang/Elements/SenchaArray.cpp b/Sencha-lang/Elements/SenchaArray.cpp
new file mode 100644
index 0000000..3d48b11
--- /dev/null
+++ b/Sencha-lang/Elements/SenchaArray.cpp
@@ -0,0 +1,48 @@
+/*
+ * SenchaArray.cpp
+ *
+ * Created on: Jan 10, 2013
+ * Author: att
+ */
+
+#include "SenchaArray.h"
+
+SenchaArray::SenchaArray() {
+ // TODO Auto-generated constructor stub
+ max_index = 0;
+}
+
+SenchaArray::~SenchaArray() {
+ // TODO Auto-generated destructor stub
+}
+
+
+SenchaArray::SenchaArray(std::string text)
+{
+ for(unsigned int i = 0; i < text.size(); i++)
+ {
+ SenchaObject temp;
+ std::string letter_string = text.substr(i, 1) ;
+ temp.text = letter_string;
+ temp.type = SenchaObject::string_literal;
+ objects.push_back(temp);
+ }
+ max_index = objects.size();
+}
+
+SenchaObject SenchaArray::get(IndexNumber index)
+{
+ return objects[index];
+}
+
+SenchaArray::IndexNumber SenchaArray::add(SenchaObject value)
+{
+ objects.push_back(value);
+ max_index = objects.size();
+ return max_index;
+}
+
+void SenchaArray::set(IndexNumber index, SenchaObject value)
+{
+ objects[index] = value;
+}
diff --git a/Sencha-lang/Elements/SenchaArray.h b/Sencha-lang/Elements/SenchaArray.h
new file mode 100644
index 0000000..09c581b
--- /dev/null
+++ b/Sencha-lang/Elements/SenchaArray.h
@@ -0,0 +1,30 @@
+/*
+ * SenchaArray.h
+ *
+ * Created on: Jan 10, 2013
+ * Author: att
+ */
+
+#ifndef SENCHAARRAY_H_
+#define SENCHAARRAY_H_
+#include <vector>
+#include "SenchaObject.h"
+#include "Element.h"
+
+class SenchaArray: public Element {
+public:
+ SenchaArray();
+ SenchaArray(std::string);
+
+ std::vector<SenchaObject> objects;
+ typedef int IndexNumber;
+
+ IndexNumber add(SenchaObject value);
+ void set(IndexNumber index, SenchaObject value);
+ IndexNumber max_index;
+ SenchaObject get(IndexNumber index);
+ //lots of stuff
+ virtual ~SenchaArray();
+};
+
+#endif /* SENCHAARRAY_H_ */