column_headers Class Reference

Provides a simple way to design a table structure. More...

#include <column_headers.h>

Inheritance diagram for column_headers:

Inheritance graph
[legend]
Collaboration diagram for column_headers:

Collaboration graph
[legend]
List of all members.

Public Types

enum  justifications { LEFT_JUSTIFY, CENTER_JUSTIFY, RIGHT_JUSTIFY }

Public Member Functions

 column_headers ()
virtual ~column_headers ()
int columns () const
 returns the current number of columns in the header list.
void add (const istring &column_name, justifications placement=LEFT_JUSTIFY, int maximum_width=0)
 adds a new column at the end of the list of columns with "column_name".
bool get (int index, istring &column_name, justifications &placement, int &maximum_width)
 returns true if the column's info can be stuffed into the parameters.
bool zap (int start, int end=-1)
 destroys the columns between "start" and "end".
bool format (istring &to_fill, const string_array &to_format)
 applies our formatting to the array "to_format".
bool format (istring &to_fill, const string_matrix &to_format)
 similar to the format() above, but operates on a matrix of strings.
virtual void pack (byte_array &packed_form) const
 packs the column headers into the byte_array "packed_form".
virtual bool unpack (byte_array &packed_form)
 unpacks the column headers from the byte_array "packed_form".

Detailed Description

Provides a simple way to design a table structure.

The column headers are managed here and allow a specification of maximum width, justification, and other properties of the column.

Definition at line 32 of file column_headers.h.


Member Enumeration Documentation

enum column_headers::justifications

Enumerator:
LEFT_JUSTIFY 
CENTER_JUSTIFY 
RIGHT_JUSTIFY 

Definition at line 41 of file column_headers.h.


Constructor & Destructor Documentation

column_headers::column_headers (  ) 

Definition at line 38 of file column_headers.cpp.

column_headers::~column_headers (  )  [virtual]

Definition at line 43 of file column_headers.cpp.

References WHACK().


Member Function Documentation

int column_headers::columns (  )  const

returns the current number of columns in the header list.

Definition at line 48 of file column_headers.cpp.

Referenced by pack(), and zap().

void column_headers::add ( const istring column_name,
justifications  placement = LEFT_JUSTIFY,
int  maximum_width = 0 
)

adds a new column at the end of the list of columns with "column_name".

it's text justification will be "placement". if "maximum_width" is non-zero, then text printed to the column can only be that many characters or less.

Definition at line 52 of file column_headers.cpp.

bool column_headers::get ( int  index,
istring column_name,
justifications placement,
int &  maximum_width 
)

returns true if the column's info can be stuffed into the parameters.

Definition at line 60 of file column_headers.cpp.

bool column_headers::zap ( int  start,
int  end = -1 
)

destroys the columns between "start" and "end".

if "end" is negative, then only the column at "start" is zapped. true is returned on success.

Definition at line 69 of file column_headers.cpp.

References columns(), and negative().

bool column_headers::format ( istring to_fill,
const string_array to_format 
)

applies our formatting to the array "to_format".

returns true if the formatting of this set of column headers can be applied to the list of strings in "to_format". if successful, "to_fill" gets stuffed with a formatted line of text based on the column design. the method can fail if there are too many or too few headers for the list in "to_format". the "to_fill" string is appended to rather than overwritten.

Definition at line 79 of file column_headers.cpp.

References array< contents >::length().

bool column_headers::format ( istring to_fill,
const string_matrix to_format 
)

similar to the format() above, but operates on a matrix of strings.

this allows the output in "to_fill" to be tailored to the available column widths; any column that was defined without a maximum width will be expanded as necessary. if any column that does have a maximum width's entries are smaller than the maximum, then the column width is shrunk appropriately.

Definition at line 87 of file column_headers.cpp.

References matrix< contents >::rows().

void column_headers::pack ( byte_array packed_form  )  const [virtual]

packs the column headers into the byte_array "packed_form".

Implements packable.

Definition at line 95 of file column_headers.cpp.

References basis::attach(), and columns().

bool column_headers::unpack ( byte_array packed_form  )  [virtual]

unpacks the column headers from the byte_array "packed_form".

Implements packable.

Definition at line 106 of file column_headers.cpp.

References basis::detach().


The documentation for this class was generated from the following files:
Generated on Fri Oct 10 04:30:05 2008 for HOOPLE Libraries by  doxygen 1.5.1