Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/etc/Divers/FileNb255.hpp File Reference

#include <j2k/Fred/Standard.hpp>
#include <j2k/Fred/JFile.cpp>

Go to the source code of this file.

Defines

#define MAX   4096

Functions

void save ()
void load ()
void toDisk ()
void fromDisk ()
void test ()

Variables

short table [4096]
char buffer [4096 *2]
size_t length = 0


Define Documentation

#define MAX   4096
 

Definition at line 17 of file FileNb255.hpp.


Function Documentation

void fromDisk  
 

Definition at line 79 of file FileNb255.hpp.

00080 {  
00081 JFile myFile( "number.txt", "rb" );
00082  myFile.putData( buffer, MAX*2 );
00083 } 

void load  
 

Definition at line 50 of file FileNb255.hpp.

00051 {
00052   register unsigned short i = 0;
00053   register unsigned char  c = NULL;
00054   register unsigned short pos = 0;
00055   memset( buffer, 0, MAX );  
00056   for( i = 0; i < MAX; i++ )
00057   {
00058     c = (UCHAR)buffer[ pos ];
00059     pos++;
00060     if ( c < 255 ) {
00061       table[ i ] = (USHORT)c;
00062     } else if ( c == 255 ) {
00063       c = (UCHAR)buffer[ pos ];
00064       pos++;
00065       table[ i ] = (USHORT)c;
00066     } else {
00067       printf( "Error: Number too big." );
00068     }
00069   }
00070   length = pos;
00071 } 

void save  
 

Definition at line 25 of file FileNb255.hpp.

00026 {
00027   register unsigned short i = 0;
00028   register unsigned char  c = NULL;
00029   register unsigned short pos = 0;
00030   memset( buffer, 0, MAX );
00031   for( i = 0; i < MAX; i++ )
00032   {
00033     if ( table[ i ] < 255 ) {
00034       c = (UCHAR)table[ i ];
00035       buffer[ pos ] = c;
00036       pos++;
00037     } else if ( table[ i ] < 510 ) {
00038       c = (UCHAR)(table[ i ] - 255);
00039       buffer[ pos ] = 255;
00040       pos++;
00041       buffer[ pos ] = c;
00042       pos++;
00043     } else {
00044       printf( "Error: Number too big." );
00045     }
00046   } 
00047   length = pos;
00048 }

void test  
 

Definition at line 85 of file FileNb255.hpp.

00086 {
00087   register unsigned short i = 0;   
00088   for( i = 0; i < MAX; i++ ) {
00089     table[ i ] = (i+200) % 300;
00090   }
00091    
00092   save();
00093   toDisk();
00094     
00095   fromDisk();
00096   load();
00097       
00098   for( i = 0; i < MAX; i++ ) {
00099     printf( "[%d]\t", table[ i ] );
00100   }
00101       
00102 }

void toDisk  
 

Definition at line 73 of file FileNb255.hpp.

00074 {
00075 JFile myFile( "number.txt", "wb" );
00076  myFile.putData( buffer, length );
00077 }


Variable Documentation

char buffer[ 4096 * 2 ]
 

Definition at line 22 of file FileNb255.hpp.

size_t length = 0
 

Definition at line 23 of file FileNb255.hpp.

Referenced by String::_substr(), and join().

short table[ 4096 ]
 

Definition at line 21 of file FileNb255.hpp.


Generated on Sun Oct 14 18:47:30 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001