Begginnig of arrays. First arrayification on strings.
parent
3ad07986ff
commit
82a5924c4e
|
@ -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;
|
||||
}
|
|
@ -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_ */
|
Loading…
Reference in New Issue