I’m using a cloud event and subscription to get a text message. Since the data is passed to the Photon as string, I’d like to be able to just pop and push the strings as they come in. I don’t really need access to the individual characters.
I can verify that the Photon does support a vector of strings; I am using in one of my projects. @ScruffR is probably correct about the method conflicts.
Thanks. #undef swap in the right place got rid of a few errors. I’m down to the following:
'no matching function for call to 'std::vector<std::__cxx11:basic_string >::push_back(String&)'
ditto "has no member named pop_front"
conversion '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string >::value_type…
I am using the std::vector<std::string> messageQueue; line.
#include "application.h"
#include "Sequencer.h"
#include "Mode.h"
#include "Repeater.h"
#include "Settings.h"
#include <vector>
#include <map>
uint8_t pi = 0; //Processing Index. Index of current element being processed.
bool Active = false; //Used to indicate that the sequence is active and processing should occur.
bool AdvanceNow = false;
bool SequenceComplete = false;
std::vector<String> Elements; //List of Modes in this sequence. Modes stored as JSON string.
std::map<uint8_t, int> RepeatTracker; //Tracks how many times the current repeat step has repeated so far.
Sequencer::Sequencer() {
}
To add to the vector I am using:
//Adds an element to the end of the sequence.
void Sequencer::Add(String JsonString) {
Elements.push_back(JsonString);
}
And to read from the vector I am using:
if (pi >= 0 && pi < Elements.size()) { //Check the index is within bounds of Elements container.
String full = Elements[pi];
}
One word of caution is that many of the std:: functions and certainly String use dynamic memory allocation. On small systems like Particle’s, this can quickly lead to heap fragmentation which can reap havoc on an otherwise seemingly stable system. The issue is not the total amount of heap available but the erosion of the largest piece of heap which can be allocated.