Provide means to check if an archive is empty

Issue #31 resolved
Klaus Iglberger created an issue

Description

A blaze::Archive can be used to store multiple vectors and matrices. However, in case their number is not know at the time of deserialization, blaze::Archive at the moment does not provide a comfortable way to extract them. For this reason, the blaze::Archive class template should provide the means to check if there are any more elements stored in the archive or if the archive is empty.

Conceptual Example

// Creating an archive that reads from the file "matrices.blaze"
blaze::Archive<std::ifstream> archive( "matrices.blaze" );

// Reading from the archive while it contains more matrices
while( !archive.isEmpty() ) {
   // Extract one more matrix
}

Tasks

  • design an API for checking if an archive is empty
  • implement the extension for the blaze::Archive class template
  • provide a full documentation of the feature
  • ensure compatibility with all existing vector and matrix classes
  • add the necessary number of test cases for the functionality

Comments (3)

  1. Klaus Iglberger reporter

    The feature has been implemented, tested, and documented as required. It is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.0.

    The Archive class template has been extended by the peek() member function, which can be used to read the next character from an input stream without extracting it. Via this function it is possible to check if the end of the input stream has been reached:

    // Creating an archive that reads from the file "matrices.blaze"
    blaze::Archive<std::ifstream> archive( "matrices.blaze" );
    
    // Reading from the archive while it contains more matrices
    while( archive.peek() != EOF ) {
       // Extract one more matrix
    }
    
  2. Log in to comment