tbx  0.7.3
resfileinfo.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2010 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef TBX_RES_RESFILEINFO_H
26 #define TBX_RES_RESFILEINFO_H
27 
28 #include "resobject.h"
29 
30 #include "../path.h"
31 
32 namespace tbx {
33 namespace res {
34 
38 class ResFileInfo : public ResObject
39 {
40 
41 public:
42  enum {CLASS_ID = 0x82ac0 };
43 
50  ResFileInfo(const ResObject &other) : ResObject(other)
51  {
52  check_class_id(CLASS_ID);
53  }
54 
60  ResFileInfo(const ResFileInfo &other) : ResObject(other)
61  {
62  }
63 
64  virtual ~ResFileInfo() {}
65 
73  {
74  other.check_class_id(CLASS_ID);
75  ResBase::operator=(other);
76  return *this;
77  }
78 
85  {
86  ResBase::operator=(other);
87  return *this;
88  }
89 
97  ResFileInfo(std::string name)
98  : ResObject(name, CLASS_ID, 100, 36+40)
99  {
100  init_message(4,0); // title
101  init_message(20,0); // file name
102  filesize(1024);
103  init_string(36,0); // window
104  }
105 
114  int flags() const {return int_value(0);}
123  void flags(int value) {int_value(0,value);}
129  bool generate_about_to_be_shown() const {return flag(0, 1<<0);}
135  void generate_about_to_be_shown(bool value) {flag(0,1<<0,value);}
141  bool generate_dialogue_completed() const {return flag(0, 1<<1);}
147  void generate_dialogue_completed(bool value) {flag(0,1<<1,value);}
148 
154  const char *title() const {return message(4);}
162  void title(const char *value, int max_length = -1) {message_with_length(4, value, max_length);}
170  void title(const std::string &value, int max_length = -1) {message_with_length(4, value, max_length);}
174  int max_title() const {return int_value(8);}
175 
181  int modified() const {return int_value(12);}
187  void modified(int value) {int_value(12,value);}
188 
194  int file_type() const {return int_value(16);}
200  void file_type(int value) {int_value(16,value);}
206  const char *file_name() const {return message(20);}
212  void file_name(const char *value) {message(20, value);}
218  void file_name(const std::string &value) {message(20, value);}
224  int filesize() const {return int_value(24);}
230  void filesize(int value) {int_value(24,value);}
231 
237  UTCTime date() const {return UTCTime(int_value(28), int_value(32));}
243  void date(UTCTime value) {int_value(28,value.centiseconds() & 0xFFFFFFFF); int_value(32, (value.centiseconds() >> 32));}
250  const char *window() const {return string(36);}
257  void window(const char *value) {string(36, value);}
264  void window(const std::string &value) {string(36, value);}
265 
266 };
267 
268 }
269 }
270 
271 #endif // TBX_RES_RESFILEINFO_H
272 
ResFileInfo & operator=(const ResFileInfo &other)
Assign from another file information window resource.
Definition: resfileinfo.h:84
ResFileInfo(std::string name)
Construct a file information window resource.
Definition: resfileinfo.h:97
int max_title() const
Get the maximum size the title can be.
Definition: resfileinfo.h:174
Class for FileInfo object template.
Definition: resfileinfo.h:38
void init_string(int offset, const char *value)
Initialise a string in a constructor helper.
Definition: resbase.cc:1725
void date(UTCTime value)
Set the data for the file info.
Definition: resfileinfo.h:243
void message_with_length(int offset, const char *value, int length=-1)
Assign a message where the length is at offset+4.
Definition: resbase.cc:1639
void modified(int value)
Set modified state.
Definition: resfileinfo.h:187
void generate_about_to_be_shown(bool value)
Set if the about to be shown event should be generated.
Definition: resfileinfo.h:135
UTCTime date() const
Get the data for the file info.
Definition: resfileinfo.h:237
void window(const std::string &value)
Set the name of the window template that provides the window for this object.
Definition: resfileinfo.h:264
void window(const char *value)
Set the name of the window template that provides the window for this object.
Definition: resfileinfo.h:257
void file_name(const std::string &value)
Set the initial file name for the file info.
Definition: resfileinfo.h:218
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
int flags() const
Raw access to all the object flags.
Definition: resfileinfo.h:114
ResFileInfo(const ResFileInfo &other)
Construct a file information window resource by copying another.
Definition: resfileinfo.h:60
const char * message(int offset) const
Get the message string at the given offset.
Definition: resbase.cc:1602
const char * file_name() const
Get the initial file name for the file info.
Definition: resfileinfo.h:206
bool generate_about_to_be_shown() const
Check if the about to be shown event should be generated.
Definition: resfileinfo.h:129
void flags(int value)
Set all the flags.
Definition: resfileinfo.h:123
int modified() const
Get modified state.
Definition: resfileinfo.h:181
const char * string(int offset) const
Return a string at the given offset.
Definition: resbase.cc:1555
void title(const std::string &value, int max_length=-1)
Set the title of the dialogue.
Definition: resfileinfo.h:170
void title(const char *value, int max_length=-1)
Set the title of the dialogue.
Definition: resfileinfo.h:162
Class to handle the 5 byte times.
Definition: path.h:51
ResFileInfo & operator=(const ResObject &other)
Assign from a ResObject.
Definition: resfileinfo.h:72
void filesize(int value)
Set the file size reported by the file info.
Definition: resfileinfo.h:230
int file_type() const
Get the initial file type for the file info resource.
Definition: resfileinfo.h:194
const char * window() const
Get the name of the window template that provides the window for this object.
Definition: resfileinfo.h:250
bool generate_dialogue_completed() const
Check if the dialogue completed event should be generated.
Definition: resfileinfo.h:141
const char * title() const
Get the title of the dialogue.
Definition: resfileinfo.h:154
ResFileInfo(const ResObject &other)
Construct a file information window resource from a ResObject.
Definition: resfileinfo.h:50
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
void file_name(const char *value)
Set the initial file name for the file info.
Definition: resfileinfo.h:212
Base class for a resource object that can be edited.
Definition: resobject.h:52
long long centiseconds() const
Get the UTC time as centiseconds.
Definition: path.h:84
void generate_dialogue_completed(bool value)
Set if the dialogue completed event should be generated.
Definition: resfileinfo.h:147
int filesize() const
Get the file size reported by the file info.
Definition: resfileinfo.h:224
void file_type(int value)
Set the initial file type for the file info resource.
Definition: resfileinfo.h:200
int int_value(int offset) const
Get an integer value.
Definition: resbase.h:316
const char * name() const
Return pointer to name of object.
Definition: resobject.h:79
void check_class_id(int class_id) const
Check if this objects class id is as specified.
Definition: resobject.cc:383
void init_message(int offset, const char *value)
Initialise a message in a constructor helper.
Definition: resbase.cc:1736