Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CPP FILE (supposed to edit this file) #include balancer.h using namespace std; HEADER FILE #ifndef BALANCER_H #define BALANCER_H #include #include #include #include /** * XHTML

image text in transcribed

CPP FILE (supposed to edit this file)

#include "balancer.h"

using namespace std;

HEADER FILE

#ifndef BALANCER_H #define BALANCER_H

#include #include #include #include

/** * XHTML Balancer class */ class Balancer { public: /** * Create a new balancer. */ Balancer();

/** * Process a new tag. * * @param aTag the lexeme (full string text) of a tag. */ void tag (std::string aTag);

/** * Inquire as to the balance status of the tags seen so far. * * @return 1 if all opening tags seen so far have been properly matched by * a closing tag * * 0 if no mismatches have been detected, but at least one opening tag * seen so far has not been properly matched by a closing tag * * -1 if we have seen at least one instance of a closing tag that * did not match the most recently added and unmatched opening tag. * Note that once a -1 has been returned, all subsequent calls to * status() must return -1, no matter what additional tags are added. */ int status () const;

private: bool error; /// > tagStack; };

#endif

3. You are given a driver for the XHTML validator. The code you are provided with will read an XHTML file and scan for any tags. It passes each tag it encounters to a Balancer whose job is to make sure that the tags are occurring in properly balanced pairs. The driver is designed to take the path to the file to be checked as a command line parameter. . /xmlcheck test0.html 4. You must implement the Balancer class. This class uses a std: : stack to track unmatched tags. The two most critical operations the Balancer class must support are - tag (string aTag): indicates that the driver has encountered a tag. The full text of the tag is passed as the parameter atag. This may be an opening tag, a closing tag, or a singleton tag. - status ( ): returns a single int indicating the status of what has been observed so far: - 1 indicates that an error has been detected. - 0 indicates that no error has been detected, but that one or more opening tags have yet to be matched - 1 indicates that no error has been detected and there are no opening tags that have yet to be matched against a closing tag

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

Students also viewed these Databases questions