Skip to content
Snippets Groups Projects
czi_parser.cpp 1.66 KiB
Newer Older
  • Learn to ignore specific revisions
  • theazgra's avatar
    theazgra committed
    #include "czi_parser.h"
    #include <fstream>
    #include "bit_converter.cpp"
    
    CziFile parse_czi_file(std::string file)
    {
        /*
        std::ifstream fileStream = std::ifstream("data/CZT-Stack-Anno.czi", std::ios::binary);
        assert(fileStream.is_open());
        // Don't read newlines in binary mode??
        fileStream.unsetf(std::ios::skipws);
    
        const int readCount = 100;
        std::vector<byte> fileHeaderBytes;
        fileHeaderBytes.resize(readCount);
    
        auto fileIterator = std::istream_iterator<byte>(fileStream);
        for (size_t i = 0; i < readCount; i++)
        {
            fileHeaderBytes[i] = *fileIterator++;
        }
        //fileStream.read(reinterpret_cast<char *>(&fileHeaderBytes), 32);
    
        printf("Read %i bytes.\n", ((int)fileHeaderBytes.size()));
    
        SegmentHeader fileSegmentHeader = {};
    
        std::vector<byte> sidBytes(fileHeaderBytes.begin(), fileHeaderBytes.begin() + 16);
    
        fileSegmentHeader.sId = utf8bytes_to_string(fileHeaderBytes, 0, 16); // bytes_to_raw_string(fileHeaderBytes, 0, 16);
        fileSegmentHeader.allocatedSize = bytes_to_long(fileHeaderBytes, 16);
        fileSegmentHeader.usedSize = bytes_to_long(fileHeaderBytes, 16 + 8);
    
        //std::vector<byte> x_guid(fileHeaderBytes.begin() + SegmentHeaderSize + 16, fileHeaderBytes.begin() + SegmentHeaderSize + 16 + 16);
    
        //std::string utf8text = "\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64";
        //std::string decoded = boost::locale::conv::from_utf<char>((char *)x_guid.data(), "utf-8");
    
        std::string guid = utf8bytes_to_string(fileHeaderBytes, SegmentHeaderSize + 16, 16);
        std::string guid2 = utf8bytes_to_string(fileHeaderBytes, SegmentHeaderSize + 32, 16);
    
        assert(guid == guid2);
        */
        return CziFile();
    }