Class BillingXml provides XML writer functions needed to create OSB XML invoices. Such writers exist for the invoice itself, each type of invoice item and all basic billing classes that need to be written to the invoice. The invoice XML writer is the entry point and should be called by the billing application to print an invoice. All XML writers are collected in a class so that you can easily store thread specific data as members of this class.
Class BillingXml contains default implementations of XML writers for commonly used billing classes. It can be extended by inheritance. In order to overload functions of this class, e.g., BillingXml::writeInfo(), remember to use a using-declaration in the derived class:
class MyBillingXml : public OSB_LIB::BillingXml { public: // Make writeInfo() functions of the base class visible using OSB_LIB::BillingXml::writeInfo; // ... }
Furthermore, note how we use dynamic_cast in connection with template functions. This seems necessary because template functions cannot be virtual.
Definition at line 113 of file billingxml.h.
OSB_LIB::BillingXmlBase::BillingXmlBase | ( | std::ostream & | o | ) | [inline] |
Constructor.
o | Output stream for the generated XML. |
Definition at line 120 of file billingxml.h.
virtual OSB_LIB::BillingXmlBase::~BillingXmlBase | ( | ) | [inline, virtual] |
virtual void OSB_LIB::BillingXmlBase::writeInvoice | ( | Invoice & | invoice, | |
const Contract & | contract, | |||
const AssociateList & | associates | |||
) | [pure virtual] |
XML writer for an OSB invoice.
This is the starting point to write an OSB XML invoice. Its main task is to invoke the writeXml() method of each invoice item on the invoice. In addition, it prints an XML header and footer and before each invoice item is written, it prints its section.
This method should not need to be overwritten except if you want to change the basic structure of an XML invoice. Instead, changes to the contents of XML invoices can be made by adding new invoice items and corresponding XML writers or customizing existing XML writers.
Here is the default implementation of writeInvoice():
void BillingXml::writeInvoice(Invoice& invoice, const Contract& contract, const AssociateList& associates) { writeXmlHeader(); for (Invoice::ItemListI i=invoice.itemListBegin(); i != invoice.itemListEnd(); ++i) { writeSection((*i)->section(), contract, associates); (*i)->writeXml(*this); } writeXmlFooter(); }
invoice | The invoice to be written. | |
contract | Contract for which the invoice is generated. | |
associates | List of all associates (owner and all product users) related to the contract. |
Implemented in OSB_LIB::BillingXml.
virtual void OSB_LIB::BillingXmlBase::writeXmlFooter | ( | ) | [pure virtual] |
virtual void OSB_LIB::BillingXmlBase::writeXmlHeader | ( | ) | [pure virtual] |
bool OSB_LIB::BillingXmlBase::globalSectionWritten_ [protected] |
Flag that indicates if the global section string was written. (Also needed by the section XML writer.).
Definition at line 203 of file billingxml.h.
Section OSB_LIB::BillingXmlBase::last_ [protected] |
Previous section.
The Section XML writer needs to know the previous section. We store it in an object and, to be thread-safe, it must be a local object in the thread.
Definition at line 197 of file billingxml.h.