1 // This file is part of a terminal todo application.
3 // Copyright (C) 2006 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
12 /// Default constructor.
13 CTodoItem::CTodoItem (id_t id
)
23 m_Priority (priority_Medium
),
25 m_bHasSublist (false),
28 const time_t now (time (NULL
));
29 m_Created
= uint32_t(now
);
33 /// Reads the object from stream \p is.
34 void CTodoItem::read (istream
& is
)
36 is
>> m_Epoch
>> m_Created
>> m_Started
>> m_Effort
>> m_Due
>> m_Done
37 >> m_Id
>> m_Priority
>> m_Progress
>> m_bHasSublist
>> m_Refs
38 >> m_Text
>> m_Comment
>> ios::align(4);
41 /// Writes the object to stream \p os.
42 void CTodoItem::write (ostream
& os
) const
44 os
<< m_Epoch
<< m_Created
<< m_Started
<< m_Effort
<< m_Due
<< m_Done
45 << m_Id
<< m_Priority
<< m_Progress
<< m_bHasSublist
<< m_Refs
46 << m_Text
<< m_Comment
<< ios::align(4);
49 /// Returns the size of the written object.
50 size_t CTodoItem::stream_size (void) const
52 return (Align (stream_size_of (m_Epoch
) +
53 stream_size_of (m_Created
) +
54 stream_size_of (m_Started
) +
55 stream_size_of (m_Effort
) +
56 stream_size_of (m_Due
) +
57 stream_size_of (m_Done
) +
58 stream_size_of (m_Id
) +
59 stream_size_of (m_Priority
) +
60 stream_size_of (m_Progress
) +
61 stream_size_of (m_bHasSublist
) +
62 stream_size_of (m_Refs
) +
63 stream_size_of (m_Text
) +
64 stream_size_of (m_Comment
), 4));
67 /// Marks the item's \p progress and sets the done time if appropriate.
68 void CTodoItem::MarkComplete (uint8_t progress
)
70 assert (progress
<= 100 && "Progress field is a percentage");
71 m_Progress
= progress
;
72 if (m_Progress
== 100)
76 /// Returns text string containing the combined date.
77 const char* CTodoItem::TimeTText (uint32_t v
) const
79 time_t t (MakeTimeT (v
));