sx360 Documentation

sx360 is a BSD licensed C++ library to handle 360 column binary files.  The 360 column binary format is tricky, and sx360 makes reading, writing, and creating these files much easier by handling the internal workings of the bit manipulation and presenting a simple interface for the developer.  sx360 also lets you create your own versions with custom punches, and column sizes.

To access or create files, two structures need to be completed and instantiated.

These are ByteMap and FileSetup

ByteMap defines how the punches will be laid out, possibly across multiple bytes.  If the default 360 column binary layout is used (which is almost every time), there is no need to fill any data in the structure.  The default is sufficient.  The default is 12 punches per column, which takes up two bytes.  Only 12 bits of the 2 bytes are used.  4 bits are wasted.

FileSetup defines how many cards per record, columns per card, and the mode with which the file should be opened.  If a file is being opened for READ or READ_WRITE, and the FileSetup::cards does not match the number that the file was created with, results will be incorrect.  FileSetup::columnsPerCard is almost always 80.  Therefore, it is important to give this information to anyone who is exchanging files.


Here is a quick sample of how to use sx360, assuming that your source directory is on the same level as sx360.

To create a file and add one record:

#include <iostream>

#include "../sx360/sxpunchfile.h"
#include "../sx360/sxiterator.h"
#include "../sx360/sxindex.h"

using namespace sx360;
using namespace std;

int main(int argc, char* const argv[])
{

    ByteMap b;  //use the default mapping of punches to bytes
    sxPunchFile f(b);

    FileSetup setup;
    setup.cards = 1; //one card per record
    setup.columnsPerCard = 80; //80 columns per card
    setup.mode = CREATE;

    f.open("binfile.bin", setup);

    sxRecord cards ( setup.cards, setup.columnsPerCard, &b );
    cards.punch(1, 1, 5, 300); //set card 1, column 1 = 0, column 2 = 0, column 3 = 5, column4 = 0, column 5 = 0
    cards.punch(1, 6, 'Y'); //set card 1, column 6 to 'Y'
    cards.punch(1, 7, "237"); //multipunch card 1, column 7, to '2','3', and 'Y'.
    f.appendRecord(&cards);

    return 0;
}


To read a file:

include <iostream>

#include "../sx360/sxpunchfile.h"
#include "../sx360/sxiterator.h"
#include "../sx360/sxindex.h"

using namespace sx360;
using namespace std;

int main(int argc, char* const argv[])
{

    ByteMap b;
    sxPunchFile f(b);

    FileSetup setup;
    setup.cards = 1;
    setup.columnsPerCard = 80;
    setup.mode = READ_ONLY;

    f.open("binfile.bin", setup);

    sxIterator* i = f.getIterator();
    sxRecord* r  = i->first();

    while (r)
    {
        cout << r->columns(1, 1, 5) << endl;
        cout << r->punched(1, 6, 'Y') << endl;
        r = i->next();
    }

    return 0;
}
 

Building sx360

The source archive for sx360 has the platform build files listed below. 

Visual Studio 2005

Xcode 2.4

autoconf/automake

The default is to create a shared object (.so) on Unix systems, and a .DLL in Visual Studio.

If you are building your own project for Win32, and not using the provided project files, the __DLL preprocessor macro is needed in your project.



For questions regarding the operation of sx360 including bugs, feature requests, send email to david@spanware.com


Visual Studio is a trademark of Microsoft Corporation
Xcode is a trademark of Apple, Inc.

2.0


Generated on Fri Jul 27 14:54:00 2007 for sx360 by  doxygen 1.5.2