Main Page | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

BinHex Class Reference

List of all members.

Detailed Description

BinHex converts data to or from BinHex format. BinHex is a format used almost exclusively on Macintosh computers for encoding files into text characters for transmission through the mail transport system or for archiving on non-Macintosh systems. The format includes the file name, file type, file creator, Macintosh Finder flags, data fork, resource fork, and checksums. In MIME, the use of BinHex is deprecated; applesingle and appledouble are the preferred format for encoding Macintosh files. The BinHex format is described in RFC 1741. BinHex is a widely used, de facto standard, but it is not an official Internet standard.

To use BinHex for converting a Macintosh file to BinHex format, call the member functions setFileName(), setFileType(), setFileCreator(), setFlag1(), setFlag2(), setDataFork(), and setResourceFork() to set the elements to be encoded. (The library sets reasonable default values for any elements that you do not set.) Then call the encode() member function to actually perform the conversion to BinHex. Finally, call binhexChars() to get the characters of the BinHex file.

To use BinHex for converting a Macintosh file from BinHex format, call the member function setBinHexChars() to set the characters of the BinHex file to be converted. Then call decode() to actually perform the conversion. Finally, call fileName(), fileType(), fileCreator(), flag1(), flag2(), dataFork(), and resourceFork() to get the decoded elements.

Note: BinHex does not change the file name in any way. When you deal with file names, you should be aware of the fact that some filenames that are valid on a Macintosh may cause problems or unexpected results on a non-Macintosh system, and vice versa. Such problem characters include slash ('/'), colon (':'), space and possibly other characters.


Public Member Functions

 BinHex ()
 Default constructor.
virtual ~BinHex ()
 Destructor.
void initialize ()
 Resets to the initial state.
const char * fileName () const
 Gets the file name.
void setFileName (const char *name)
 Sets the file name.
void fileType (char *buf) const
 Gets the file type.
void setFileType (const char *type)
 Sets the file type.
void fileCreator (char *buf) const
 Gets the file creator.
void setFileCreator (const char *creator)
 Sets the file creator.
uint8_t flag1 () const
 Gets the first byte of the Macintosh Finder flags.
void setFlag1 (uint8_t flag)
 Sets the first byte of the Macintosh Finder flags.
uint8_t flag2 () const
 Gets the second byte of the Macintosh Finder flags.
void setFlag2 (uint8_t flag)
 Sets the second byte of the Macintosh Finder flags.
const StringdataFork () const
 Gets the data fork for the file.
void setDataFork (const String &bytes)
 Sets the data fork for the file.
const StringresourceFork () const
 Gets the resource fork for the file.
void setResourceFork (const String &bytes)
 Sets the resource fork for the file.
const StringbinhexChars () const
 Gets the characters of the BinHex encoded file.
void setBinHexChars (const String &chars)
 Sets the characters of the BinHex encoded file.
void encode ()
 Converts the Macintosh file information to BinHex format.
int decode ()
 Converts the Macintosh file information from BinHex format.


Constructor & Destructor Documentation

BinHex  ) 
 

Default constructor.

~BinHex  )  [virtual]
 

Destructor.


Member Function Documentation

const String & binhexChars  )  const
 

Gets the characters of the BinHex encoded file.

Returns:
the encoded characters of the BinHex file

const String & dataFork  )  const
 

Gets the data fork for the file.

For files that originate on non-Macintosh systems, such as GIF or JPEG files, the file data should be set as the data fork.

Returns:
the bytes of the data fork

int decode  ) 
 

Converts the Macintosh file information from BinHex format.

Returns zero if the decode operation completes successufully; otherwise, the function returns -1.

Returns:
0 on success; -1 on failure

void encode  ) 
 

Converts the Macintosh file information to BinHex format.

void fileCreator char *  buf  )  const
 

Gets the file creator.

Most Macintosh files have a creator, which is represented by a signature of four bytes. The creator specifies which application to launch when a file's icon is double clicked. buf should point to an array of at least four characters.

Parameters:
buf buffer of at least four bytes that contains the file creator on output

const char * fileName  )  const
 

Gets the file name.

The file name is restricted to a maximum length of 63 characters.

Returns:
the file name

void fileType char *  buf  )  const
 

Gets the file type.

All Macintosh files have a file type, which is represented by four bytes. Some examples include "TEXT" for a text file, or "APPL" for an application. buf should point to an array of at least four characters.

Parameters:
buf buffer of at least four bytes that contains the file type on output

uint8_t flag1  )  const
 

Gets the first byte of the Macintosh Finder flags.

For files that originate on non-Macintosh systems, this byte should be set to zero (the default).

Returns:
the first byte of the Finder flags

uint8_t flag2  )  const
 

Gets the second byte of the Macintosh Finder flags.

For files that originate on non-Macintosh systems, this byte should be set to zero (the default).

Returns:
the second byte of the Finder flags

void initialize  ) 
 

Resets the object's internal state to its initial state.

You may call this member function to reuse the object for more than one encode or decode operation.

const String & resourceFork  )  const
 

Gets the resource fork for the file.

For files that originate on non-Macintosh systems, such as GIF or JPEG files, the resource fork should normally be empty.

Returns:
the bytes of the resource fork

void setBinHexChars const String chars  ) 
 

Sets the characters of the BinHex encoded file.

Parameters:
chars the encoded characters of the BinHex file

void setDataFork const String bytes  ) 
 

Sets the data fork for the file.

For files that originate on non-Macintosh systems, such as GIF or JPEG files, the file data should be set as the data fork.

Parameters:
bytes the bytes of the data fork

void setFileCreator const char *  creator  ) 
 

Sets the file creator.

Most Macintosh files have a creator, which is represented by a signature of four bytes. The creator specifies which application to launch when a file's icon is double clicked. creator should point to an array of at least four characters.

Parameters:
creator the file creator

void setFileName const char *  name  ) 
 

Sets the file name.

The file name is restricted to a maximum length of 63 characters.

Parameters:
name the file name

void setFileType const char *  type  ) 
 

Sets the file type.

All Macintosh files have a file type, which is represented by four bytes. Some examples include "TEXT" for a text file, or "APPL" for an application. type should point to an array of at least four characters.

Parameters:
type the file type

void setFlag1 uint8_t  flag  ) 
 

Sets the first byte of the Macintosh Finder flags.

For files that originate on non-Macintosh systems, this byte should be set to zero (the default).

Parameters:
flag the first byte of the Finder flags

void setFlag2 uint8_t  flag  ) 
 

Sets the second byte of the Macintosh Finder flags.

For files that originate on non-Macintosh systems, this byte should be set to zero (the default).

Parameters:
flag the second byte of the Finder flags

void setResourceFork const String bytes  ) 
 

Sets the resource fork for the file.

For files that originate on non-Macintosh systems, such as GIF or JPEG files, the resource fork should normally be empty.

Parameters:
bytes the bytes of the resource fork

Copyright © 2001-2007 Hunny Software, Inc. All rights reserved.