1 ///////////////////////////////////////////////////////////////////////////////
5 #define MEMFC_TITLE 0x01
6 #define MEMFC_BODY 0x02
7 #define MEMFC_MEMO_TYPE 0x03
8 #define MEMFC_CATEGORY 0x04
9 #define MEMFC_END 0xffff
11 FieldLink
<Memos
> MemosFieldLinks
[] = {
12 { MEMFC_TITLE
, "Title", 0, 0, &Memos::Title
, 0, 0 },
13 { MEMFC_BODY
, "Body", 0, 0, &Memos::Body
, 0, 0 },
14 { MEMFC_CATEGORY
, "Category", 0, 0, &Memos::Category
, 0, 0 },
15 { MEMFC_END
, "End of List", 0, 0, 0, 0, 0 }
27 const unsigned char* Memos::ParseField(const unsigned char *begin
,
28 const unsigned char *end
)
30 const CommonField
*field
= (const CommonField
*) begin
;
32 // advance and check size
33 begin
+= COMMON_FIELD_HEADER_SIZE
+ btohs(field
->size
);
34 if( begin
> end
) // if begin==end, we are ok
37 if( !btohs(field
->size
) ) // if field has no size, something's up
40 if( field
->type
== MEMFC_MEMO_TYPE
) {
41 if( ( MemoType
= field
->u
.raw
[0] ) != 'm' ) {
42 throw Error( "Memos::ParseField: MemoType is not 'm'" );
48 // cycle through the type table
49 for( FieldLink
<Memos
> *b
= MemosFieldLinks
;
53 if( b
->type
== field
->type
) {
55 std::string
&s
= this->*(b
->strMember
);
56 s
.assign((const char *)field
->u
.raw
, btohs(field
->size
)-1);
57 return begin
; // done!
59 else if( b
->timeMember
&& btohs(field
->size
) == 4 ) {
60 time_t &t
= this->*(b
->timeMember
);
61 t
= min2time(field
->u
.min1900
);
66 // if still not handled, add to the Unknowns list
68 uf
.type
= field
->type
;
69 uf
.data
.assign((const char*)field
->u
.raw
, btohs(field
->size
));
70 Unknowns
.push_back(uf
);
72 // return new pointer for next field
76 void Memos::ParseHeader(const Data
&data
, size_t &offset
)
78 // no header in Memos records
81 void Memos::ParseFields(const Data
&data
, size_t &offset
)
83 const unsigned char *finish
= ParseCommonFields(*this,
84 data
.GetData() + offset
, data
.GetData() + data
.GetSize());
85 offset
+= finish
- (data
.GetData() + offset
);
89 void Memos::Dump(std::ostream
&os
) const
91 os
<< "Memos entry: 0x" << setbase(16) << RecordId
92 << " (" << (unsigned int)RecType
<< ")\n";
93 os
<< " Title: " << Title
<< "\n";
94 os
<< " Body: " << Body
<< "\n";
95 os
<< " Category: " << Category
<< "\n";