Task Description: Implement Chunked Data Handling Functionality
Your objective is to implement the chunked data handling functionality in the C++ application based on the provided test code. Follow the specifications below:
Implement the TChunkedDataWriter class:
This class should allow writing data into discrete blocks. Each block can be created with a default or a specified name, and the data can be of various types (e.g., int, std::string, custom structs).
Ensure that the NewBlock() method can either create an unnamed block or a named block when a string is provided.
Implement the Write() method to write data into the current block.
Implement WriteFooter() to finalize the writing process, ensuring that any necessary metadata (such as block sizes and names) is stored correctly.
Implement the TChunkedDataReader class:
This class should be able to read previously written chunked data from a binary format.
Implement methods such as GetBlockLen(size_t index) to retrieve the length of a block by its index.
Provide a method GetBlockByName(const std::string& name) to retrieve data from a block by its name.
Implement the necessary internal mechanisms to maintain the collection of blocks and their associated metadata.
Implement a TStringsVectorWriter class:
This class should be capable of handling collection types specifically for strings. It should allow strings to be pushed into a buffer similar to TChunkedDataWriter.
Error Handling:
Implement error handling for invalid block access which should throw exceptions if an out-of-bounds index or a non-existent block name is accessed.
Matrix Handling:
Ensure that your implementation supports various data types—like integers, strings, and user-defined structs (e.g., TPodStruct) as shown in the tests.
Testing:
Ensure that all existing unit tests in TChunkedHelpersTest and TChunkedDataTest pass successfully.
Pay close attention to test cases regarding empty blocks, named blocks, and the ability to retrieve data by both index and name.
Implementation Location:
Place all new or modified functionality in the /app/ directory of the project structure.
Make sure your code is efficient, adheres to C++ best practices, and is well-documented for maintainability.