summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/Elements/SenchaArray.cpp
blob: be69825635097663e1469f95114da62ef9629dbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * SenchaArray.cpp
 *
 *  Created on: Jan 10, 2013
 *      Author: att
 */

#include "SenchaArray.h"



SenchaArray::SenchaArray(std::string name, ContextManager * context_manager) {
	// TODO Auto-generated constructor stub
	max_index = 0;
	this->context_manager = context_manager;
	this->name = name;
	context_manager->get_top()->add(name, SenchaObject());
}

SenchaArray::~SenchaArray() {
	// TODO Auto-generated destructor stub
}


SenchaArray::SenchaArray(std::string name, ContextManager * context_manager, std::string text)
{
	max_index = 0;
	this->context_manager = context_manager;
	this->name = name;
	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;
		context_manager->get_top()->add("_" + name+ "_" + to_string(i), temp);
		//objects.push_back(temp);
	}
	max_index = text.size();
	//context->add(name, SenchaObject(text));
}

SenchaObject SenchaArray::get(IndexNumber index)
{
	SenchaObject result =  context_manager->get_top()->get("_" + name +"_"  +to_string(index));
	result.name = "_" + name + "_"  + to_string(index);
	return result;
 //return objects[index];
}

SenchaArray::IndexNumber SenchaArray::add(SenchaObject value)
{
	context_manager->get_top()->add("_" + name+ "_" + to_string(max_index), value);
	max_index++;

	return max_index;
}

void SenchaArray::set(IndexNumber index, SenchaObject value)
{
	//objects[index] = value;
	context_manager->get_top()->add("_" + name +"_" +to_string(index), value);
}