winIDEA SDK
isys::IEmitter Class Referenceabstract

Description

This interface defines methods to be implemented by concrete emitters.

Emitters are classes, which receive data from data objects, and write it to the given stream in specific format. For example, isys::CXMLEmitter writes the data in XML format.
This abstract class can be used from C++ only.

Example:

  CfileStreamSPtr xmlReportFileStream(new CFileStream("fullReport.xml"));
  IEmitterSPtr xmlReportEmitter = ic.EmitterFactory.createXmlEmitter(xmlReportFileStream);
  xmlReportEmitter.startStream('<?xml-stylesheet type="text/xsl" href="itestResult.xslt"?>\n');

  // add content
  xmlReportEmitter.startDocument(true);
  testResult_1.serialize(xmlReportEmitter);
  xmlReportEmitter.endDocument(true);

  xmlReportEmitter.startDocument(true);
  testResult_2.serialize(xmlReportEmitter);
  xmlReportEmitter.endDocument(true);

  xmlReportEmitter.endStream();
  xmlReportFileStream.close();
See also
isys::CYAMLEmitter and isys::CXMLEmitter

#include <IEmitter.h>

Inheritance diagram for isys::IEmitter:
isys::CXMLEmitter isys::CYAMLEmitter

Public Types

enum  EObjectType
 This enum defines which type of object will be serialized. More...
 
enum  EYamlStyle {
  EYAML_ANY_STYLE , EYAML_FLOW_STYLE ,
  EYAML_BLOCK_STYLE
}
 Enumeration of YAML styles. More...
 

Public Member Functions

virtual void endDocument (bool implicit)=0
 Ends the document. More...
 
virtual void endStream ()=0
 Ends output stream. More...
 
virtual std::string escapeSpecialChars (const std::string &data)=0
 This method modifies the input string so that it is in proper syntax for scalars. More...
 
virtual void flush ()=0
 Flush the accumulated characters to the output.
 
virtual std::string getIndent ()
 Returns indentation string added to each line of output.
 
virtual int getLineNumber ()
 This method provides information about current line being written to the file. More...
 
virtual void getRow (iconnect::StrVector &row, int rowIndex)
 This method returns row for the given index. More...
 
virtual void setIndent (const std::string &indent)
 Sets indentation string added to each line of output.
 
virtual void setLineNumber (int lineNumber)
 Can be used to set current line number in cases, where emitter does not start at the beginning of the stream, or to disable line counting by setting 'lineNumber' to LINE_NUM_NOT_SET. More...
 
virtual void startDocument (bool implicit)=0
 Starts the document. More...
 
virtual void startStream ()=0
 Initializes the output stream object.
 
virtual void startStream (const std::string &userData)=0
 Initializes the output stream object. More...
 
virtual void writeText (const std::string &text)=0
 Writes unmodified text to output.
 

Member Enumeration Documentation

◆ EObjectType

This enum defines which type of object will be serialized.

It is use only by some emitters, because mapping from hierarchical to table structure depends on object being serialized, this enum is used to select the right mapping.

◆ EYamlStyle

Enumeration of YAML styles.

Enumerator
EYAML_ANY_STYLE 

any style is allowed

EYAML_FLOW_STYLE 

uses [] for sequences, {} for maps

EYAML_BLOCK_STYLE 

moves to next line

Member Function Documentation

◆ endDocument()

virtual void isys::IEmitter::endDocument ( bool  implicit)
pure virtual

Ends the document.

Parameters
implicitif the document end indicator is implicit. It is considered as a stylistic parameter and may be ignored by the emitter. If true, YAML emitter adds terminating doc sequence: '...'

Implemented in isys::CXMLEmitter, and isys::CYAMLEmitter.

◆ endStream()

virtual void isys::IEmitter::endStream ( )
pure virtual

Ends output stream.

The output stream is NOT closed. Call this method after emitting is done.

Implemented in isys::CXMLEmitter, and isys::CYAMLEmitter.

◆ escapeSpecialChars()

virtual std::string isys::IEmitter::escapeSpecialChars ( const std::string &  data)
pure virtual

This method modifies the input string so that it is in proper syntax for scalars.

See CYAMLEmitter::escapeSpecialChars() and CXMLEmitter::escapeSpecialChars().

Implemented in isys::CXMLEmitter, and isys::CYAMLEmitter.

◆ getLineNumber()

virtual int isys::IEmitter::getLineNumber ( )
virtual

This method provides information about current line being written to the file.

Not all emitters may provide this information. If emitter does not keep track of line numbers, this method should return LINE_NUM_NOT_SET. Emitter may return the number of all lines (for example CCSVEmitter).

◆ getRow()

virtual void isys::IEmitter::getRow ( iconnect::StrVector row,
int  rowIndex 
)
virtual

This method returns row for the given index.

Not all emitters may implement this method - an exception is throw in such case.

◆ setLineNumber()

virtual void isys::IEmitter::setLineNumber ( int  lineNumber)
virtual

Can be used to set current line number in cases, where emitter does not start at the beginning of the stream, or to disable line counting by setting 'lineNumber' to LINE_NUM_NOT_SET.

This is also the default value, so to enable line counting, call this method with value >= 0.

◆ startDocument()

virtual void isys::IEmitter::startDocument ( bool  implicit)
pure virtual

Starts the document.

This method should be called after startStream().

Parameters
implicitcurrently used by YAML emitter only. When true, the document is emitted without the leading '—'.

Implemented in isys::CXMLEmitter, and isys::CYAMLEmitter.

◆ startStream()

virtual void isys::IEmitter::startStream ( const std::string &  userData)
pure virtual

Initializes the output stream object.

Parameters
userDatatext written directly to output stream, bypassing the underlying emitter. This can be used for writing comments or preprocessing instructions.

Implemented in isys::CXMLEmitter, and isys::CYAMLEmitter.