MCPcopy Create free account
hub / github.com/KDE/labplot / readAttachmentList

Method readAttachmentList

src/3rdparty/liborigin/OriginAnyParser.cpp:992–1098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

990}
991
992void OriginAnyParser::readAttachmentList()
993{
994 LOG_PRINT(logfile, "readAttachmentList()\n")
995 /* Attachments are divided in two groups (which can be empty)
996 first group is preceded by two integers: 4096 (0x1000) and number_of_attachments followed as
997 usual by a '\n' mark second group is a series of (header, name, data) triplets without the '\n'
998 mark.
999 */
1000
1001 // figure out if first group is not empty. In this case we will read integer=8 at current file
1002 // position
1003 unsigned int att_1st_empty = 0;
1004 file >> att_1st_empty;
1005 file.seekg(-4, ios_base::cur);
1006
1007 istringstream stmp(ios_base::binary);
1008 string att_header;
1009 if (att_1st_empty == 8) {
1010 // first group
1011 unsigned int att_list1_size = 0;
1012
1013 // get two integers
1014 // next line fails if first attachment group is empty: readObjectSize exits as there is no
1015 // '\n' after 4 bytes for uint
1016 att_list1_size = readObjectSize(); // should be 8 as we expect two integer values
1017 curpos = file.tellg();
1018 string att_list1 = readObjectAsString(att_list1_size);
1019 LOG_PRINT(logfile, "First attachment group at %" PRId64 " [0x%" PRIx64 "]", curpos, curpos)
1020
1021 stmp.str(att_list1);
1022
1023 unsigned int att_mark = 0, number_of_atts = 0, iattno = 0, att_data_size = 0;
1024 GET_INT(stmp, att_mark) // should be 4096
1025 GET_INT(stmp, number_of_atts)
1026 LOG_PRINT(logfile, " with %u attachments.\n", number_of_atts)
1027
1028 for (unsigned int i = 0; i < number_of_atts; i++) {
1029 /* Header is a group of 7 integers followed by \n
1030 1st attachment mark (4096: 0x00 0x10 0x00 0x00)
1031 2nd attachment number ( <num_of_att)
1032 3rd attachment size
1033 4th .. 7th ???
1034 */
1035 // get header
1036 att_header = readObjectAsString(7 * 4);
1037 stmp.str(att_header);
1038 GET_INT(stmp, att_mark) // should be 4096
1039 GET_INT(stmp, iattno)
1040 GET_INT(stmp, att_data_size)
1041 curpos = file.tellg();
1042 LOG_PRINT(logfile, "Attachment no %d (%d) at %" PRId64 " [0x%" PRIx64 "], size %d\n", i,
1043 iattno, curpos, curpos, att_data_size)
1044
1045 // get data
1046 string att_data = readObjectAsString(att_data_size);
1047 // even if att_data_size is zero, we get a '\n' mark
1048 if (att_data_size == 0)
1049 file.seekg(1, ios_base::cur);

Callers

nothing calls this directly

Calls 5

seekgMethod · 0.45
tellgMethod · 0.45
eofMethod · 0.45
readMethod · 0.45
gcountMethod · 0.45

Tested by

no test coverage detected