Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a C++ code using the argument manager given below. #include #include #include #include using namespace std; // This is a class that can parse

Create a C++ code using the argument manager given below.

image text in transcribedimage text in transcribedimage text in transcribed

#include  #include  #include  #include  using namespace std; // This is a class that can parse the commnad line arguments we use in COSC 2430 homework. class ArgumentManager { private: map m_argumentMap; public: ArgumentManager() { } ArgumentManager(int argc, char *argv[], char delimiter=';'); ArgumentManager(string rawArguments, char delimiter=';'); void parse(int argc, char *argv[], char delimiter=';'); void parse(string rawArguments, char delimiter=';'); string get(string argumentName); string toString(); friend ostream& operator  1) { for (int i=1; i::iterator iter = m_argumentMap.find(argumentName); //If the argument is not found, return a blank string. if (iter == m_argumentMap.end()) { return ""; } else { return iter->second; } } string ArgumentManager::toString() { stringstream ss; for (map::iterator iter = m_argumentMap.begin(); iter != m_argumentMap.end(); iter++) { ss first second  

input11.txt

{genre:fantasy,title:Harry.Potter,author:J.K.Rowling,year:1997} {genre:dystopian,t it le:Hunger .Ga me s, au t h o r:Suzanne.Collins, y e ar: 2008} {genre:fantasy,title:The.Lord.Of.The.Rings,author:J.R.R.Tolkien,year:1954} {genre:fantasy,author:Brandon.Sanderson,title:The.Way.Of.Kings,year:2010} 

input12.txt

{genre:fiction,title:Oliver.Twist,author:Cha rles.Dickens,year:18 38} {genre:child.literature,title:the.cat.in.the. hat,author:Dr.Seus s,year:1957} {genre:child.lit e rature,ti tle:Green.Eggs.And.H am, author:Dr.Seu ss,year:1960} {genre:ficti on,title:Great.Expec tations,autho r:Char les.Dickens,year:1861} {genre:f ict i on, title:A.Chrismas.Carol,author:Charles.D icke ns,year:1843} {genre:fict ion ,title : The.House.Of.The.Dead,a uthor:Fyod or.Dostoevsky,year:1861} {genre:fiction,titl e:The.Old.Man.And.The.Sea,author:Ernest.Hemingway,year:1957} {g e n re: f ic tion , title:Gr eat.Exp ectation s,auth or:Charles.Dickens,year:1861} {genre:chi ld.literat u r e, ti tl e:G reen.Eggs.A nd.Ha m, auth or:Dr.Seuss,year:1960}

input13.txt

{genre:fiction,title:Oliver.Twist,author:Cha rles.Dickens,year:18 38} {genre:child.literature,title:the.cat.in.the. hat,author:Dr.Seus s,year:1957} {genre:child.lit e rature,ti tle:Green.Eggs.And.H am, author:Dr.Seu ss,year:1960} {genre:ficti on,title:Great.Expec tations,autho r:Char les.Dickens,year:1861} {genre:f ict i on, title:A.Chrismas.Carol,author:Charles.D icke ns,year:1843} {genre:fict ion ,title : The.House.Of.The.Dead,a uthor:Fyod or.Dostoevsky,year:1861} {genre:fiction,titl e:The.Old.Man.And.The.Sea,author:Ernest.Hemingway,year:1957} 

command11.txt (empty)

command12.txt

genre:fiction year:1861 year:1957

command13.txt

title:Harry.Potter
2. Input, Command, Output and example files a. Input file The input file will contain a list of books, that contains their title, the author and the year it was published. It can contain anywhere from 0 to 10000 books. Each book will be boxed in by brackets and there may be empty lines or unnecessary spacing. There are four different categories (the categories must appear in this order for the information to be valid) a. genre b. title c. author d. year In between each bracket there must be a title author and year in that order. If the categories are misspelled(case sensitive), missing or out of order then they aren't valid and shouldn't be added to your data. The category won't count as misspelled if it has a space in the middle of it Examples of Correct data: (genre fantasy, title:Harry Potter, author. JK Rowling year: 1997) genre:dy s toplan, title:Hunger Games,aut n or.Suzanne Collins, ye ar. 2008) //Excess spaces are fine but should be removed in the output Examples of Incorrect data: author JK Rowling title:Harry.Potter.year:1997) out of order Assumptions: o each category will be followed by a colon and will have some amount of letters and periods behind it None of the words will have commas, colons or brackets in them. These symbols will only appear as they do in these examples, even in invalid data. The only way data can be invalid is if the categories (genre, author, title, year) are missing or misspelled and they don't this doesn't mean the actual title of the book is misspelled as that would be hard to implement) So long as it fits this template the actual titles and and genres can be complete gibberish Duplicate information is allowed and should be repeated in the output file b. Command file I. The command file will contain any number of the categories (1.e: title, author or year) followed by a colon and what it's looking for. You will then look through the books you have and output all the books that match all the categories in the command file. II. If the command file is empty then every single correct input should be printed If multiple of the same category are in the command file that means that any of as long as a book contains one of those names then it should be produced. IV. If every category is mentioned in the command file then the book must match with one of the specified categories in order to appear in the output A EX: If the command file asks for three different years and three different titles then the book must match one of the titles and one of the years for it to show up in the output file. c. Output file The output file will contain all the books specified by the command file in order they appeared in the input file (with the extra spaces removed). There should be no empty lines in this (the last line can be emptied and it won't change anything) III. The only books not mentioned should be the invalid one's from the input and books not specified in the command file IV. If there are no books that match the command file then the output file should be empty d. Examples Ex1: input11.txt: genre:fantasy.title:Harry.Potter author.J.KRowling.year: 1997) genre.dystopian, title:Hunger Ga me sauth or Suzanne Collins, ye ar: 2008) genre fantasy.title.The.Lord. Of. The.Rings.author:J.R.R.Tolkien year: 1954) genre.fantasy author Brandon Sanderson, title: The.Way.Of.Kings year.2010) command 11.txt: (Empty) 1. II. i. ans 11.txt: genre fantasy, title:Harry.Potter, author JK Rowling year:1997) (genre dystopian, title:Hunger Games author Suzanne Collins, year 2008) genre fantasy, title:The.Lord. Of The Rings author.J.R.R.Toliden,year:1954) Linux Command: ./files "input-input11.txt command=command1 1.txt,output=output1 1.txt" ii. Ex2: input12.txt {genre fiction, title:Oliver. Twist, author:Charles Dickens,year:18 38} {genre:child.literature, title:the.cat.in.the. hat, author:Dr. Seus s.year 1957) {genre:child.lit e rature, title:Green.Eggs.And.H am author:Dr. Seuss,year:1960} {genrefiction, title:Great. Expectations, author Charles Dick ens.year:1861} {genre:fiction, title:A. Christmas Carol, author Charles.Dicke ns.year:1843) {genre:fiction title : The.House.Of.The.Dead, a uthor:Fyod or.Dostoevsky.year 1861} {genre:fiction, title:The Old.Man.And. The Sea,author: Emest.Hemingway.year:1957) {g en re:fic tion , title:Great. Expectation s, author:Charles Dickens,year: 1861} {genre:chi Id.literature, ti ti e:Green.Eggs. And.Ham,author:Dr. Seuss.year:1960} command12.txt genre:fiction year:1861 year:1957 iii. ans 12.txt {genre-fiction, title:Great.Expectations, author:Charles.Dickens,year:1861} (genre fiction, title:The.House.Of.The.Dead, author:Fyodor Dostoevsky,year1861} {genre:fiction, title:The Old. Man.And.The. Sea, author:Ernest.Hemingway, year:1957) {genre-fiction, title:Great. Expectations, author:Charles Dickens,year:1861) Linux Command: ./files "input-input12.txt;command=command12.txt;output-output 12.txt" Ex3: input13.txt {genre fiction, title:Oliver. Twist, author:Charles Dickens,year:18 38} {genre:child.literature, title:the.cat.in.the. hat,author:Dr. Seus s.year: 1957) {genre:child.lite rature, ti tle:Green.Eggs. And.H am, author:Dr. Seuss.year: 1960) {title:fiction, genre:Great.Expectations, author:Charles Dickens,year: 1861} {genrae:fiction, title:A. Christmas Carol, author:Charles Dickens,year: 1843} {genred:fiction title : The.House.Of.The.Dead, a uthor:Fyod or.Dostoevsky.year:1861} {genremispelled:fiction, title:The Old. Man.And.The.Sea,author:Ernest Hemingway.year:1957) command13.txt title:Harry.Potter ans 13.txt (empty) Linux Command: ./files "input-input13.txt;command=command 13.txt;output-output13.txt" 2. Input, Command, Output and example files a. Input file The input file will contain a list of books, that contains their title, the author and the year it was published. It can contain anywhere from 0 to 10000 books. Each book will be boxed in by brackets and there may be empty lines or unnecessary spacing. There are four different categories (the categories must appear in this order for the information to be valid) a. genre b. title c. author d. year In between each bracket there must be a title author and year in that order. If the categories are misspelled(case sensitive), missing or out of order then they aren't valid and shouldn't be added to your data. The category won't count as misspelled if it has a space in the middle of it Examples of Correct data: (genre fantasy, title:Harry Potter, author. JK Rowling year: 1997) genre:dy s toplan, title:Hunger Games,aut n or.Suzanne Collins, ye ar. 2008) //Excess spaces are fine but should be removed in the output Examples of Incorrect data: author JK Rowling title:Harry.Potter.year:1997) out of order Assumptions: o each category will be followed by a colon and will have some amount of letters and periods behind it None of the words will have commas, colons or brackets in them. These symbols will only appear as they do in these examples, even in invalid data. The only way data can be invalid is if the categories (genre, author, title, year) are missing or misspelled and they don't this doesn't mean the actual title of the book is misspelled as that would be hard to implement) So long as it fits this template the actual titles and and genres can be complete gibberish Duplicate information is allowed and should be repeated in the output file b. Command file I. The command file will contain any number of the categories (1.e: title, author or year) followed by a colon and what it's looking for. You will then look through the books you have and output all the books that match all the categories in the command file. II. If the command file is empty then every single correct input should be printed If multiple of the same category are in the command file that means that any of as long as a book contains one of those names then it should be produced. IV. If every category is mentioned in the command file then the book must match with one of the specified categories in order to appear in the output A EX: If the command file asks for three different years and three different titles then the book must match one of the titles and one of the years for it to show up in the output file. c. Output file The output file will contain all the books specified by the command file in order they appeared in the input file (with the extra spaces removed). There should be no empty lines in this (the last line can be emptied and it won't change anything) III. The only books not mentioned should be the invalid one's from the input and books not specified in the command file IV. If there are no books that match the command file then the output file should be empty d. Examples Ex1: input11.txt: genre:fantasy.title:Harry.Potter author.J.KRowling.year: 1997) genre.dystopian, title:Hunger Ga me sauth or Suzanne Collins, ye ar: 2008) genre fantasy.title.The.Lord. Of. The.Rings.author:J.R.R.Tolkien year: 1954) genre.fantasy author Brandon Sanderson, title: The.Way.Of.Kings year.2010) command 11.txt: (Empty) 1. II. i. ans 11.txt: genre fantasy, title:Harry.Potter, author JK Rowling year:1997) (genre dystopian, title:Hunger Games author Suzanne Collins, year 2008) genre fantasy, title:The.Lord. Of The Rings author.J.R.R.Toliden,year:1954) Linux Command: ./files "input-input11.txt command=command1 1.txt,output=output1 1.txt" ii. Ex2: input12.txt {genre fiction, title:Oliver. Twist, author:Charles Dickens,year:18 38} {genre:child.literature, title:the.cat.in.the. hat, author:Dr. Seus s.year 1957) {genre:child.lit e rature, title:Green.Eggs.And.H am author:Dr. Seuss,year:1960} {genrefiction, title:Great. Expectations, author Charles Dick ens.year:1861} {genre:fiction, title:A. Christmas Carol, author Charles.Dicke ns.year:1843) {genre:fiction title : The.House.Of.The.Dead, a uthor:Fyod or.Dostoevsky.year 1861} {genre:fiction, title:The Old.Man.And. The Sea,author: Emest.Hemingway.year:1957) {g en re:fic tion , title:Great. Expectation s, author:Charles Dickens,year: 1861} {genre:chi Id.literature, ti ti e:Green.Eggs. And.Ham,author:Dr. Seuss.year:1960} command12.txt genre:fiction year:1861 year:1957 iii. ans 12.txt {genre-fiction, title:Great.Expectations, author:Charles.Dickens,year:1861} (genre fiction, title:The.House.Of.The.Dead, author:Fyodor Dostoevsky,year1861} {genre:fiction, title:The Old. Man.And.The. Sea, author:Ernest.Hemingway, year:1957) {genre-fiction, title:Great. Expectations, author:Charles Dickens,year:1861) Linux Command: ./files "input-input12.txt;command=command12.txt;output-output 12.txt" Ex3: input13.txt {genre fiction, title:Oliver. Twist, author:Charles Dickens,year:18 38} {genre:child.literature, title:the.cat.in.the. hat,author:Dr. Seus s.year: 1957) {genre:child.lite rature, ti tle:Green.Eggs. And.H am, author:Dr. Seuss.year: 1960) {title:fiction, genre:Great.Expectations, author:Charles Dickens,year: 1861} {genrae:fiction, title:A. Christmas Carol, author:Charles Dickens,year: 1843} {genred:fiction title : The.House.Of.The.Dead, a uthor:Fyod or.Dostoevsky.year:1861} {genremispelled:fiction, title:The Old. Man.And.The.Sea,author:Ernest Hemingway.year:1957) command13.txt title:Harry.Potter ans 13.txt (empty) Linux Command: ./files "input-input13.txt;command=command 13.txt;output-output13.txt

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

Progress Monitoring Data Tracking Organizer

Authors: Teacher'S Aid Publications

1st Edition

B0B7QCNRJ1

More Books

Students also viewed these Databases questions

Question

What steps should be taken to address any undesirable phenomena?

Answered: 1 week ago