home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 2.ddi / CLASSEXM.ZIP / FILEDATA.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  7.6 KB  |  302 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // Contents ----------------------------------------------------------------
  4. //
  5. //      fileDataClass
  6. //      filesByNameClass
  7. //      filesByDateClass
  8. //      filesBySizeClass
  9. //
  10. //      FileData
  11. //
  12. //      FilesByName
  13. //      FilesByName::isEqual
  14. //      FilesByName::isLessThan
  15. //
  16. //      FilesByDate
  17. //      FilesByDate::isEqual
  18. //      FilesByDate::isLessThan
  19. //
  20. //      FilesBySize
  21. //      FilesBySize::isEqual
  22. //      FilesBySize::isLessThan
  23. //
  24. // Description
  25. //
  26. //      Defines file data classes.  These classes are used by DIRECTRY.CPP,
  27. //      which is part of the directory listing example program for the
  28. //      Turbo C++ class library.
  29. //
  30. // End ---------------------------------------------------------------------
  31.  
  32. // Interface Dependencies ---------------------------------------------------
  33.  
  34. #ifndef __FILEDATA_H
  35. #define __FILEDATA_H
  36.  
  37. #ifndef __DIR_H
  38. #include <dir.h>
  39. #define __DIR_H
  40. #endif
  41.  
  42. #ifndef __CLSDEFS_H
  43. #include <clsdefs.h>
  44. #endif
  45.  
  46. #ifndef __SORTABLE_H
  47. #include <sortable.h>
  48. #endif
  49.  
  50. #ifndef __STRNG_H
  51. #include <strng.h>
  52. #endif
  53.                                                              
  54. #ifndef __LDATE_H
  55. #include <ldate.h>
  56. #endif
  57.  
  58. #ifndef __LTIME_H
  59. #include <ltime.h>
  60. #endif
  61.  
  62. // End Interface Dependencies ------------------------------------------------
  63.  
  64.  
  65. // Macro //
  66.  
  67. // Summary -----------------------------------------------------------------
  68. //
  69. //      Defines a values for the file classes.  We start from the first
  70. //      available user class number.  The class numbers are defined
  71. //      in CLSDEFS.H, in the class library INCLUDE directory.
  72. //
  73. // End ---------------------------------------------------------------------
  74.  
  75. #define     fileDataClass       __firstUserClass
  76. #define     filesByNameClass    (fileDataClass+1)
  77. #define     filesByDateClass    (filesByNameClass+1)
  78. #define     filesBySizeClass    (filesByDateClass+1)
  79.  
  80. // Class //
  81.  
  82. class FileData: public Sortable
  83. {
  84. public:
  85.                             FileData( ffblk& );
  86.     virtual classType       isA() const { return fileDataClass; }
  87.     virtual char           *nameOf() const { return "FileData"; }
  88.     virtual int             isEqual( const Object& ) const = 0;
  89.     virtual int             isLessThan( const Object& ) const = 0;
  90.     virtual hashValueType   hashValue() const { return 0; }
  91.     virtual void            printOn( ostream& ) const;
  92. protected:
  93.     String                  fileName;
  94.     Date                    fileDate;
  95.     Time                    fileTime;
  96.     long                    fileSize;
  97. };
  98.  
  99. // Description -------------------------------------------------------------
  100. //
  101. //      Defines a base file class.  Class FileData is derived from the
  102. //      class Sortable, which is part of the class library.
  103. //
  104. // Constructor
  105. //
  106. //      FileData
  107. //
  108. //      Constructs a FileData object from the DOS file block.
  109. //
  110. // Public Members
  111. //
  112. //      isA
  113. //
  114. //      Returns the class type of FileData.
  115. //
  116. //      nameOf
  117. //
  118. //      Returns a pointer to the character string "FileData."
  119. //
  120. //      isEqual
  121. //
  122. //      Determines whether two file data objects are equal.
  123. //      Redeclared as pure virtual.
  124. //
  125. //      isLessThan
  126. //      Determines whether one file data object is less than another.
  127. //      Redeclared as pure virtual.
  128. //      
  129. //      hashValue
  130. //
  131. //      Returns a pre-defined hash value for a FileData object.
  132. //
  133. //      printOn
  134. //
  135. //      Prints the contents of a file data object.
  136. //
  137. // End ---------------------------------------------------------------------
  138.  
  139.  
  140. // Class //
  141.  
  142. class FilesByName:  public FileData
  143. {
  144. public:
  145.                             FilesByName( ffblk& blk ) : FileData( blk ) {}
  146.     virtual classType       isA() const { return filesByNameClass; }
  147.     virtual char           *nameOf() const { return "FilesByName"; }
  148.     virtual int             isEqual( const Object& ) const;
  149.     virtual int             isLessThan( const Object& ) const;
  150. };
  151.  
  152. // Description -------------------------------------------------------------
  153. //
  154. //      Defines a file class which is sorted by name.  Class FilesByName
  155. //      is derived from the class FileData, which is a user-defined
  156. //      base class.
  157. //
  158. // Constructor
  159. //
  160. //      FilesByName
  161. //
  162. //      Constructs a FilesByName object from the DOS file block.
  163. //
  164. // Public Members
  165. //
  166. //      isA
  167. //
  168. //      Returns the class type of FilesByName.
  169. //
  170. //      nameOf
  171. //
  172. //      Returns a pointer to the character string "FilesByName."
  173. //
  174. //      isEqual
  175. //
  176. //      Determines whether two file data objects are equal.
  177. //
  178. //      isLessThan
  179. //      Determines whether one file data object is less than another.
  180. //      
  181. // Inherited Members
  182. //
  183. //      hashValue
  184. //
  185. //      Inherited from FileData.
  186. //
  187. //      printOn
  188. //
  189. //      Inherited from FileData.
  190. //
  191. // End ---------------------------------------------------------------------
  192.  
  193.  
  194. // Class //
  195.  
  196. class FilesByDate:  public FileData
  197. {
  198. public:
  199.                             FilesByDate( ffblk& blk ) : FileData( blk ) {}
  200.     virtual classType       isA() const { return filesByDateClass; }
  201.     virtual char           *nameOf() const { return "FilesByDate"; }
  202.     virtual                 isEqual( const Object& ) const;
  203.     virtual                 isLessThan( const Object& ) const;
  204. };
  205.  
  206. // Description -------------------------------------------------------------
  207. //
  208. //      Defines a file class which is sorted by date.  Class FilesByDate
  209. //      is derived from the class FileData, which is a user-defined
  210. //      base class.
  211. //
  212. // Constructor
  213. //
  214. //      FilesByDate
  215. //
  216. //      Constructs a FilesByDate object from the DOS file block.
  217. //
  218. // Public Members
  219. //
  220. //      isA
  221. //
  222. //      Returns the class type of FilesByDate.
  223. //
  224. //      nameOf
  225. //
  226. //      Returns a pointer to the character string "FilesByDate."
  227. //
  228. //      isEqual
  229. //
  230. //      Determines whether two file data objects are equal.
  231. //
  232. //      isLessThan
  233. //      Determines whether one file data object is less than another.
  234. //      
  235. // Inherited Members
  236. //
  237. //      hashValue
  238. //
  239. //      Inherited from FileData.
  240. //
  241. //      printOn
  242. //
  243. //      Inherited from FileData.
  244. //
  245. // End ---------------------------------------------------------------------
  246.  
  247.  
  248. // Class //
  249.  
  250. class FilesBySize:  public FileData
  251. {
  252. public:
  253.                             FilesBySize( ffblk& blk ) : FileData( blk ) {}
  254.     virtual classType       isA() const { return filesBySizeClass; }
  255.     virtual char           *nameOf() const { return "FilesBySize"; }
  256.     virtual                 isEqual( const Object& ) const;
  257.     virtual                 isLessThan( const Object& ) const;
  258. };
  259.  
  260. // Description -------------------------------------------------------------
  261. //
  262. //      Defines a file class which is sorted by size.  Class FilesBySize
  263. //      is derived from the class FileData, which is a user-defined
  264. //      base class.
  265. //
  266. // Constructor
  267. //
  268. //      FilesBySize
  269. //
  270. //      Constructs a FilesBySize object from the DOS file block.
  271. //
  272. // Public Members
  273. //
  274. //      isA
  275. //
  276. //      Returns the class type of FilesBySize.
  277. //
  278. //      nameOf
  279. //
  280. //      Returns a pointer to the character string "FilesBySize."
  281. //
  282. //      isEqual
  283. //
  284. //      Determines whether two file data objects are equal.
  285. //
  286. //      isLessThan
  287. //      Determines whether one file data object is less than another.
  288. //      
  289. // Inherited Members
  290. //
  291. //      hashValue
  292. //
  293. //      Inherited from FileData.
  294. //
  295. //      printOn
  296. //
  297. //      Inherited from FileData.
  298. //
  299. // End ---------------------------------------------------------------------
  300.  
  301. #endif    // __FILEDATA_H //
  302.