#include <SIO_functions.h>
Static Public Member Functions | |
| unsigned int | data (SIO_stream *, char *, const int) |
| unsigned int | data (SIO_stream *, unsigned char *, const int) |
| unsigned int | data (SIO_stream *, short *, const int) |
| unsigned int | data (SIO_stream *, unsigned short *, const int) |
| unsigned int | data (SIO_stream *, int *, const int) |
| unsigned int | data (SIO_stream *, unsigned int *, const int) |
| unsigned int | data (SIO_stream *, float *, const int) |
| unsigned int | data (SIO_stream *, double *, const int) |
| unsigned int | pointed_at (SIO_stream *, SIO_POINTER_DECL *) |
| unsigned int | pointer_to (SIO_stream *, SIO_POINTER_DECL *) |
| bool | validateName (const char *) |
Static Private Member Functions | |
| void | copy (unsigned char *, unsigned char *, const int, const int) |
| unsigned int | xfer (SIO_stream *, const int, const int, unsigned char *) |
Friends | |
| class | SIO_stream |
| class | SIO_record |
|
||||||||||||||||||||
|
Referenced by SIO_stream::write(), and SIO_record::write(). |
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||
|
Definition at line 403 of file SIO_functions.cc. References SIO_LEN_QB, SIO_MODE_READ, SIO_POINTER_DECL, SIO_STREAM_SUCCESS, UCHR_CAST, and xfer().
00407 {
00408
00409 static unsigned int
00410 SIO_ptag = 0xffffffff;
00411
00412 //
00413 // Whether reading or writing the basic principle of SIO_pointed_at is to
00414 // build a map of pairs of values called the 'pointed at' table. The routine
00415 // SIO_pointer_to builds a similar table called the 'pointer to' table. The
00416 // first value in each table is the 'match' value. When writing, both tables
00417 // have the same layout:
00418 //
00419 // First value: Pointer to a memory location
00420 // Second value: Offset in the output buffer
00421 //
00422 // When reading, that changes to:
00423 //
00424 // First value: Simple 32-bit integer value read from the buffer
00425 // Second value: Pointer to a memory location
00426 //
00427 // That means that these tables have different 'shapes' depending on whether
00428 // the program is reading or writing. Given that a stream must be either
00429 // read or write, I was loath to allocate four tables when at most two
00430 // would ever be used. I have therefore reused the same tables for both
00431 // purposes. Hmmm. Maybe not the world's best decision. I have been
00432 // forced to use a lot of 'reinterpret_cast' statements to make it all
00433 // work (a process complicated by the fact that pointers are not the same
00434 // size on all architectures).
00435 //
00436
00437 //
00438 // Write. Save the memory location of this object along with the offset
00439 // in the output buffer where the generated match quantity must go. Put
00440 // a placeholder in the output buffer (it will be overwritten at the "output
00441 // relocation" stage).
00442 //
00443 if( stream->mode != SIO_MODE_READ )
00444 {
00445 std::pair< void* const, void* >
00446 entry( xfer,
00447 reinterpret_cast<void *>( stream->buffer - stream->bufloc ) );
00448
00449 stream->pointedAt->insert( entry );
00450
00451 return( SIO_functions::xfer( stream, SIO_LEN_QB, 1, UCHR_CAST(&SIO_ptag)));
00452 }
00453
00454 //
00455 // Read. Keep a record of the "match" quantity read from the buffer and
00456 // the location in memory which will need relocating.
00457 //
00458 else
00459 {
00460 unsigned int
00461 match,
00462 status;
00463
00464 status = SIO_functions::xfer( stream, SIO_LEN_QB, 1, UCHR_CAST( &match ) );
00465 if( !( status & 1 ) )
00466 return( status );
00467
00468 //
00469 // Ignore match = SIO_ptag . This is basically a pointer target which was
00470 // never relocated when the record was written. i.e. nothing points to it!
00471 // Don't clutter the maps with information that can never be used.
00472 //
00473 if( match != SIO_ptag )
00474 {
00475 std::pair< void* const, void* >
00476 entry( reinterpret_cast<void *>(match), xfer );
00477
00478 stream->pointedAt->insert( entry );
00479 }
00480 }
00481
00482 //
00483 // That's all folks!
00484 //
00485 return( SIO_STREAM_SUCCESS );
00486 }
|
|
||||||||||||
|
Definition at line 492 of file SIO_functions.cc. References SIO_LEN_QB, SIO_MODE_READ, SIO_POINTER_DECL, SIO_STREAM_SUCCESS, UCHR_CAST, and xfer().
00496 {
00497 static unsigned int
00498 SIO_pntr = 0x00000000; // Placeholder value for 'pointer to'
00499
00500 void
00501 *ifer; // Indirect xfer (actually **xfer)
00502
00503 //
00504 // xfer is really a pointer-to-a-pointer. This routine is most interested
00505 // in the value of *xfer when treated as a pointer. C++ tends to object
00506 // to this as being 'not type safe'. To keep the compiler happy (and purists
00507 // miserable), do one 'reinterpret_cast' immediately to make later code
00508 // easier to read.
00509 //
00510 ifer = reinterpret_cast<void *>(*xfer);
00511
00512 //
00513 // Whether reading or writing the basic principle of SIO_pointer_to is to
00514 // build a map of pairs of values called the 'pointer to' table. The routine
00515 // SIO_pointed_at builds a similar table called the 'pointed at' table. The
00516 // first value in each table is the 'match' value. When writing, both tables
00517 // have the same layout:
00518 //
00519 // First value: Pointer to a memory location
00520 // Second value: Offset in the output buffer
00521 //
00522 // When reading, that changes to:
00523 //
00524 // First value: Simple 32-bit integer value read from the buffer
00525 // Second value: Pointer to a memory location
00526 //
00527 // That means that these tables have different 'shapes' depending on whether
00528 // the program is reading or writing. Given that a stream must be either
00529 // read or write, I was loath to allocate four tables when at most two
00530 // would ever be used. I have therefore reused the same tables for both
00531 // purposes. Hmmm. Maybe not the world's best decision. I have been
00532 // forced to use a lot of 'reinterpret_cast' statements to make it all
00533 // work (a process complicated by the fact that pointers are not the same
00534 // size on all architectures).
00535 //
00536
00537 //
00538 // Write. Keep a record of the "match" quantity (i.e. the value of the
00539 // pointer (which may be different lengths on different machines!)) and
00540 // the current offset in the output buffer. Put a placeholder in the
00541 // output buffer (it will be overwritten at the "output relocation" stage).
00542 //
00543 if( stream->mode != SIO_MODE_READ )
00544 {
00545 //
00546 // Ignore NULL pointers. These are always recorded in the buffer with a
00547 // zero match word (and are treated specially when read back). There's no
00548 // point in putting useless information in the maps.
00549 //
00550 if( ifer != NULL )
00551 {
00552 std::pair< void* const, void* >
00553 entry( ifer,
00554 reinterpret_cast<void *>(stream->buffer - stream->bufloc) );
00555
00556 stream->pointerTo->insert( entry );
00557 }
00558 return( SIO_functions::xfer( stream, SIO_LEN_QB, 1, UCHR_CAST(&SIO_pntr)));
00559 }
00560
00561 //
00562 // Read. Keep a record of the "match" quantity read from the buffer and
00563 // the location in memory which will need relocating.
00564 //
00565 else
00566 {
00567 unsigned int
00568 match,
00569 status;
00570
00571 status = SIO_functions::xfer( stream, SIO_LEN_QB, 1, UCHR_CAST( &match ) );
00572 if( !( status & 1 ) )
00573 return( status );
00574
00575 //
00576 // Ignore match = SIO_pntr. This is basically a null pointer which can
00577 // never be relocated, so don't fill the multimap with a lot of useless
00578 // information.
00579 //
00580 //
00581 // C cast replaces static_cast for:
00582 //
00583 // std::pair
00584 // entry( static_cast<void *>(match),
00585 // static_cast<void *>(xfer) );
00586 //
00587 if( match != SIO_pntr )
00588 {
00589 std::pair< void* const, void* >
00590 entry( reinterpret_cast<void *>(match), xfer );
00591
00592 stream->pointerTo->insert( entry );
00593 }
00594
00595 //
00596 // Hand -something- back to the caller. The number passed back is -not-
00597 // a pointer, and pointer relocation will not occur until the whole record
00598 // has been read. The only circumstance where the next line is important
00599 // is the case of a NULL pointer which the caller may be relying on to
00600 // find the end of (for instance) a singly linked list.
00601 //
00602 //04/01/2001 T.Abe comment out temporary...
00603 *xfer = static_cast<SIO_POINTER_DECL>(match);
00604 }
00605
00606 //
00607 // That's all folks!
00608 //
00609 return( SIO_STREAM_SUCCESS );
00610 }
|
|
|
Definition at line 629 of file SIO_functions.cc. Referenced by SIO_streamManager::add(), SIO_recordManager::add(), and SIO_blockManager::add().
00632 {
00633
00634 //
00635 // Just do it!
00636 //
00637 if( *name < 0 ) return( false );
00638 if( !isalpha( (int)*name ) && *name != '_' ) return( false );
00639
00640 for( name += 1; *name != '\0'; name++ )
00641 {
00642 if( *name < 0 ) return( false );
00643 if( !isalnum( (int)*name ) && *name != '_' ) return( false );
00644 }
00645
00646 //
00647 // That's all folks!
00648 //
00649 return( true );
00650 }
|
|
||||||||||||||||||||
|
Referenced by pointed_at(), and pointer_to(). |
|
|
Definition at line 125 of file SIO_functions.h. |
|
|
Definition at line 124 of file SIO_functions.h. |
1.3.4