Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help filling in this code, I am creating a class in C++ to parse through a string and each method needs to be

I need help filling in this code, I am creating a class in C++ to parse through a string and each method needs to be filled in. The parameters and directions for each method are commented out above the start of the method. Help would be greatly appreciated!

#include #include #include #include "../327_proj3_test/includes/StringParserClass.h" #include "../327_proj3_test/includes/constants.h"

namespace KP_StringParserClass{

class StringParserClass {

//dont forget to initialize member variables StringParserClass(void){

}

//call cleanup to release any allocated memory virtual ~StringParserClass(void){

}

//these are the start tag and the end tags that we want to find, //presumably the data of interest is between them, please make a //COPY of what pStartTag and pEndTag point to. In other words //DO NOT SET pStartTag = pStart //returns: //SUCCESS //ERROR_TAGS_NULL if either pStart or pEnd is null int setTags(const char *pStart, const char *pEnd){

}

//First clears myVector //going to search thru pDataToSearchThru, looking for info bracketed by //pStartTag and pEndTag, will add that info only to myVector //returns //SUCCESS finished searching for data between tags, results in myVector (0 or more entries) //ERROR_TAGS_NULL if either pStart or pEnd is null //ERROR_DATA_NULL pDataToSearchThru is null int getDataBetweenTags(char *pDataToSearchThru, std::vector &myVector){

}

void cleanup(){

}

//Searches a string starting at pStart for pTagToLookFor //returns: //SUCCESS found pTagToLookFor, pStart points to beginning of tag and pEnd points to end of tag //FAIL did not find pTagToLookFor and pEnd points to 0 //ERROR_TAGS_NULL if either pStart or pEnd is null int findTag(char *pTagToLookFor, char *&pStart, char *&pEnd){

}

char *pStartTag; char *pEndTag; bool areTagsSet; } }

Header files are given below that I have implemented into the .cpp file above. There is also a FileIO class I have written but I don't think that this stringparser class needs to implement any of that.

/* * StringParserClass.h * * Created on: Oct 8, 2017 * Author: keith */ #ifndef STRINGPARSER_H_ #define STRINGPARSER_H_

#include #include

namespace KP_StringParserClass{

class StringParserClass { public:

//dont forget to initialize member variables StringParserClass(void);

//call cleanup to release any allocated memory virtual ~StringParserClass(void);

//these are the start tag and the end tags that we want to find, //presumably the data of interest is between them, please make a //COPY of what pStartTag and pEndTag point to. In other words //DO NOT SET pStartTag = pStart //returns: //SUCCESS //ERROR_TAGS_NULL if either pStart or pEnd is null int setTags(const char *pStart, const char *pEnd);

//First clears myVector //going to search thru pDataToSearchThru, looking for info bracketed by //pStartTag and pEndTag, will add that info only to myVector //returns //SUCCESS finished searching for data between tags, results in myVector (0 or more entries) //ERROR_TAGS_NULL if either pStart or pEnd is null //ERROR_DATA_NULL pDataToSearchThru is null int getDataBetweenTags(char *pDataToSearchThru, std::vector &myVector);

private: void cleanup();

//Searches a string starting at pStart for pTagToLookFor //returns: //SUCCESS found pTagToLookFor, pStart points to beginning of tag and pEnd points to end of tag //FAIL did not find pTagToLookFor and pEnd points to 0 //ERROR_TAGS_NULL if either pStart or pEnd is null int findTag(char *pTagToLookFor, char *&pStart, char *&pEnd);

char *pStartTag; char *pEndTag; bool areTagsSet; }; } #endif

* constants.h * * Created on: Oct 8, 2017 * Author: keith */

#ifndef CONSTANTS_H_ #define CONSTANTS_H_ #include

//common const int SUCCESS = 0;

//stringparser specific error conditions const int FAIL = SUCCESS-1; const int ERROR_NO_ERROR = SUCCESS-2; const int ERROR_TAGS_NULL = SUCCESS-3; const int ERROR_DATA_NULL = SUCCESS-4;

//fileIO specific error conditions const int COULD_NOT_OPEN_FILE_TO_READ = SUCCESS-5; const int COULD_NOT_OPEN_FILE_TO_WRITE = SUCCESS-6;

//test app specific info const int FAIL_WRONG_NUMBER_ARGS = -6; const int EXPECTED_NUMBER_ARGUMENTS =5; const std::string WRONG_NUMB_ARGS = "This program expects 4 arguments, inputfile starttag endtag outputfile";

#endif /* CONSTANTS_H_ */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions