Isis 3 Programmer Reference
Isis::PvlFormat Class Reference

Formats a Pvl name value pair to Isis standards. More...

#include <PvlFormat.h>

Inheritance diagram for Isis::PvlFormat:
Inheritance graph
Collaboration diagram for Isis::PvlFormat:
Collaboration graph

Public Member Functions

 PvlFormat (const QString &file)
 
 PvlFormat (Pvl &keymap)
 
void add (const QString &file)
 
void add (Pvl &keymap)
 
void setCharLimit (const unsigned int limit)
 Sets the maximum number of characters in a keyword value that can be printed to a line before it wraps to the next line.
 
unsigned int charLimit () const
 Retrieves the maximum number of characters in a keyword value that can be printed to a line before it wraps to the next line.
 
virtual QString formatValue (const PvlKeyword &keyword, int valueIndex=0)
 
virtual QString formatName (const PvlKeyword &keyword)
 
virtual QString formatEnd (const QString name, const PvlKeyword &keyword)
 
virtual QString formatEOL ()
 
virtual KeywordType type (const PvlKeyword &keyword)
 
virtual int accuracy (const PvlKeyword &keyword)
 

Protected Member Functions

virtual QString addQuotes (const QString value)
 
bool isSingleUnit (const PvlKeyword &keyword)
 Returns true if the units are the same for all value in the keyword otherwise it returns false.
 

Protected Attributes

QString m_keywordMapFile
 
Pvl m_keywordMap
 
unsigned int m_charLimit
 Maximum number of characters on a single line of a keyword value.
 

Private Member Functions

void init ()
 Clears all PvlFormat data.
 

Detailed Description

Formats a Pvl name value pair to Isis standards.

This class is used to format a single PVL keyword-value pair using normal Isis formatting. The class serves as a base class for others to override and implement their own formatting.

This class uses a Pvl or Pvl formatted file to populate its internal data structure. This structure is used to lookup the type of a keyword and/or other information for another Pvl{Object|Group|Keyword}. The format of the file or Pvl is:

NAME=TYPE
NAME2=(TYPE,PLACES)

Example:

DESCRIPTION = STRING
MinimumLatitude = (REAL,5)
BITTYPE = ENUM
RECORDS = INTEGER

Where NAME is the name of a keyword in the Pvl to be formatted. TYPE is the type of keyword (STRING,BOOL,INTEGER,REAL,OCTAL,HEX,BINARY,ENUM) (see ToKeywordType). PLACES is the number of digits to the right of the decimal place for a keyword of TYPE REAL.

NOTE: The capabilities to use this Pvl are not implemented in this base class. They are provided as a convience for child classes only. This class only implements the normal Isis foramatting, which is not dependent on the type of the keyword. It is dependent on value of the keyword.

Author
2006-09-05 Stuart Sides
History

2006-09-05 Stuart Sides - Original version

2008-09-30 Christopher Austin - added FormatEOL()

2009-12-17 Steven Lambright - {} are now treated the same as ()

2010-02-04 Travis Addair - Added SetCharLimit method allowing users to set the point at which a keyword value is output to the next line down.

2010-12-09 Steven Lambright - Values ending in '-' no longer fail to be quoted properly

2013-03-11 Steven Lambright and Mathew Eis - Brought method names and member variable names up to the current Isis 3 coding standards. Fixes #1533.

2013-06-03 Tracie Sucharski and Jeannie Backer - Fixed the addQuotes method to better handle multi-dimensional arrays vs equations with multiple sets of parens. Fixes #569.

Definition at line 108 of file PvlFormat.h.

Constructor & Destructor Documentation

◆ PvlFormat() [1/3]

Isis::PvlFormat::PvlFormat ( )

Definition at line 23 of file PvlFormat.cpp.

◆ PvlFormat() [2/3]

Isis::PvlFormat::PvlFormat ( const QString & file)

Definition at line 36 of file PvlFormat.cpp.

◆ PvlFormat() [3/3]

Isis::PvlFormat::PvlFormat ( Pvl & keymap)

Definition at line 49 of file PvlFormat.cpp.

◆ ~PvlFormat()

virtual Isis::PvlFormat::~PvlFormat ( )
inlinevirtual

Definition at line 115 of file PvlFormat.h.

Member Function Documentation

◆ accuracy()

int Isis::PvlFormat::accuracy ( const PvlKeyword & keyword)
virtual

Definition at line 129 of file PvlFormat.cpp.

◆ add() [1/2]

void Isis::PvlFormat::add ( const QString & file)

Definition at line 68 of file PvlFormat.cpp.

◆ add() [2/2]

void Isis::PvlFormat::add ( Pvl & keymap)

Definition at line 90 of file PvlFormat.cpp.

◆ addQuotes()

QString Isis::PvlFormat::addQuotes ( const QString value)
protectedvirtual

Definition at line 227 of file PvlFormat.cpp.

◆ charLimit()

unsigned int Isis::PvlFormat::charLimit ( ) const
inline

Retrieves the maximum number of characters in a keyword value that can be printed to a line before it wraps to the next line.

By default, the limit is set to 80 characters.

Returns
unsigned int Maximum number of characters.

Definition at line 138 of file PvlFormat.h.

References m_charLimit.

Referenced by Isis::PvlKeyword::writeWithWrap().

◆ formatEnd()

QString Isis::PvlFormat::formatEnd ( const QString name,
const PvlKeyword & keyword )
virtual

Definition at line 215 of file PvlFormat.cpp.

◆ formatEOL()

virtual QString Isis::PvlFormat::formatEOL ( )
inlinevirtual

Definition at line 147 of file PvlFormat.h.

◆ formatName()

QString Isis::PvlFormat::formatName ( const PvlKeyword & keyword)
virtual

Definition at line 204 of file PvlFormat.cpp.

◆ formatValue()

QString Isis::PvlFormat::formatValue ( const PvlKeyword & keyword,
int valueIndex = 0 )
virtual

Definition at line 147 of file PvlFormat.cpp.

◆ init()

void Isis::PvlFormat::init ( )
private

Clears all PvlFormat data.

Definition at line 56 of file PvlFormat.cpp.

References Isis::PvlObject::clear(), and m_charLimit.

◆ isSingleUnit()

bool Isis::PvlFormat::isSingleUnit ( const PvlKeyword & keyword)
protected

Returns true if the units are the same for all value in the keyword otherwise it returns false.

Parameters
keywordThe PvlKeyword to be formatted

Definition at line 307 of file PvlFormat.cpp.

References Isis::PvlKeyword::size(), Isis::PvlKeyword::stringEqual(), and Isis::PvlKeyword::unit().

◆ setCharLimit()

void Isis::PvlFormat::setCharLimit ( const unsigned int limit)
inline

Sets the maximum number of characters in a keyword value that can be printed to a line before it wraps to the next line.

By default, the limit is set to 80 characters.

Parameters
limitThe new character limit.

Definition at line 127 of file PvlFormat.h.

References m_charLimit.

◆ type()

KeywordType Isis::PvlFormat::type ( const PvlKeyword & keyword)
virtual

Definition at line 111 of file PvlFormat.cpp.

Member Data Documentation

◆ m_charLimit

unsigned int Isis::PvlFormat::m_charLimit
protected

Maximum number of characters on a single line of a keyword value.

Definition at line 163 of file PvlFormat.h.

Referenced by charLimit(), init(), and setCharLimit().

◆ m_keywordMap

Pvl Isis::PvlFormat::m_keywordMap
protected

Definition at line 160 of file PvlFormat.h.

◆ m_keywordMapFile

QString Isis::PvlFormat::m_keywordMapFile
protected

Definition at line 159 of file PvlFormat.h.


The documentation for this class was generated from the following files: