#include<iostream> #include<string> #include<vector> #include<rapidjson/document.h>…
- User
#include #include #include #include<rapidjson/document.h> #include<rapidjson/filereadstream.h> #include
using namespace std; using namespace rapidjson;
class FSMBase { public: string StateName; string EventName; std::vector<FSMBase*> subitem;
public:
FSMBase() { std::cout << "default constructor called" << std::endl; } void getdata() { std::cout << "FSMBase called" << std::endl; } virtual void Add(FSMBase* b1) { subitem.push_back(b1); b1->getdata(); } ~FSMBase() { std::cout << " destructor called" << std::endl; }};
class premitivetool:public FSMBase { public:
void Add( FSMBase* b1) { subitem.push_back(b1); b1->getdata(); }};
class Event: public FSMBase { string ActionType; string ActionParam; public:
void getdata(string Name, string ActType, string ActPar) { EventName = Name; ActionType = ActType; ActionParam = ActPar; std::cout << " " << EventName << " " << ActionType << " " << ActionParam << std::endl; }};
class state:public FSMBase { string EntreyMethodName; //state* nextstate; std::vector<Event*> eventitem; public: /*state(string statename,Event *e1) {
eventitem.push_back(e1); e1->getdata("a","b","c");pk }*/ void getdata(string Name,string Methodname) { StateName = Name; EntreyMethodName = Methodname; std::cout << " " << StateName << " " << EntreyMethodName<<std::endl; } void Add(FSMBase * fsmbase1) { subitem.push_back(fsmbase1); fsmbase1->getdata(); }};
int main() { state *State1; State1 = new state; Event *Event1; Event1 = new Event; State1->getdata("StartToolState", "EnterStartTool"); State1->Add(Event1);
premitivetool* prtool1; prtool1 = new premitivetool; prtool1->Add(State1); state* State2; State2= new state; Event* Event2; Event2 = new Event; Event2->getdata("MotionEvent","InvokeMethod","MoveToolPoints"); State1->Add(Event1); State1->Add(Event2); prtool1->Add(State2); delete Event2; delete State2; delete State1; delete Event1; // Open the file ifstream file("FSMImplementationJSON.json"); // Read the entire file into a string string json((istreambuf_iterator<char>(file)), istreambuf_iterator<char>()); Document doc; // Parse the JSON data doc.Parse(json.c_str()); //std::cout << doc["Name"].GetString() << std::endl; // Check for parse errors if (doc.HasParseError()) { cerr << "Error parsing JSON: " << doc.GetParseError() << endl; return 1; } FILE* fp; //errno_t err; fopen_s(&fp,"FSMImplementationJSON.json", "rb"); assert(fp != nullptr); //// Use a FileReadStream to // // read the data from the file char readBuffer[65536]; rapidjson::FileReadStream is(fp, readBuffer,sizeof(readBuffer)); if (fp == nullptr) { std::cerr << "Error opening the file" << std::endl; return 1; } // // using a Document object rapidjson::Document d; d.ParseStream(is); - Assistant
- User
what is actually parsing
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.