Cident.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. //---------------------------------------------------------------------------
  2. //
  3. // cident.h - This file contains the class declarations for misc file stuff
  4. //
  5. //
  6. //---------------------------------------------------------------------------//
  7. // Copyright (C) Microsoft Corporation. All rights reserved. //
  8. //===========================================================================//
  9. #ifndef CIDENT_H
  10. #define CIDENT_H
  11. //---------------------------------------------------------------------------
  12. // Include files
  13. #ifndef DSTD_H
  14. #include "dstd.h"
  15. #endif
  16. #ifndef DIDENT_H
  17. #include "dident.h"
  18. #endif
  19. #include <string.h>
  20. //---------------------------------------------------------------------------
  21. // Externs
  22. //---------------------------------------------------------------------------
  23. //---------------------------------------------------------------------------
  24. // class IDString
  25. //---------------------------------------------------------------------------
  26. class IDString
  27. {
  28. protected:
  29. char id[ID_SIZE]; // 8 characters and a terminator...
  30. public:
  31. void init (void)
  32. {
  33. memset(id,0,ID_SIZE);
  34. }
  35. void init (char *new_id)
  36. {
  37. strncpy(id,new_id,ID_SIZE-1); // pads unused ID with 0s!
  38. id[ID_SIZE-1] = 0;
  39. }
  40. void init (IDString & new_ids)
  41. {
  42. strncpy(id,new_ids.id,ID_SIZE-1);
  43. id[ID_SIZE-1] = 0;
  44. }
  45. IDString (void)
  46. {
  47. init();
  48. }
  49. IDString (char * new_id)
  50. {
  51. init(new_id);
  52. }
  53. IDString (IDString & new_ids)
  54. {
  55. init(new_ids);
  56. }
  57. inline operator char * (void)
  58. {
  59. return id;
  60. }
  61. bool operator == (char *other_id)
  62. {
  63. if( other_id[0]!=id[0] )
  64. return FALSE;
  65. if( other_id[0]==0 )
  66. return TRUE;
  67. if( other_id[1]!=id[1] )
  68. return FALSE;
  69. if( other_id[1]==0 )
  70. return TRUE;
  71. if( other_id[2]!=id[2] )
  72. return FALSE;
  73. if( other_id[2]==0 )
  74. return TRUE;
  75. if( other_id[3]!=id[3] )
  76. return FALSE;
  77. if( other_id[3]==0 )
  78. return TRUE;
  79. if( other_id[4]!=id[4] )
  80. return FALSE;
  81. if( other_id[4]==0 )
  82. return TRUE;
  83. if( other_id[5]!=id[5] )
  84. return FALSE;
  85. if( other_id[5]==0 )
  86. return TRUE;
  87. if( other_id[6]!=id[6] )
  88. return FALSE;
  89. if( other_id[6]==0 )
  90. return TRUE;
  91. return (other_id[7]==id[7]);
  92. // return (strncmp(id,other_id,ID_SIZE-1) == 0);
  93. }
  94. bool operator == (IDString &other_ids)
  95. {
  96. if( other_ids.id[0]!=id[0] )
  97. return FALSE;
  98. if( other_ids.id[0]==0 )
  99. return TRUE;
  100. if( other_ids.id[1]!=id[1] )
  101. return FALSE;
  102. if( other_ids.id[1]==0 )
  103. return TRUE;
  104. if( other_ids.id[2]!=id[2] )
  105. return FALSE;
  106. if( other_ids.id[2]==0 )
  107. return TRUE;
  108. if( other_ids.id[3]!=id[3] )
  109. return FALSE;
  110. if( other_ids.id[3]==0 )
  111. return TRUE;
  112. if( other_ids.id[4]!=id[4] )
  113. return FALSE;
  114. if( other_ids.id[4]==0 )
  115. return TRUE;
  116. if( other_ids.id[5]!=id[5] )
  117. return FALSE;
  118. if( other_ids.id[5]==0 )
  119. return TRUE;
  120. if( other_ids.id[6]!=id[6] )
  121. return FALSE;
  122. if( other_ids.id[6]==0 )
  123. return TRUE;
  124. return (other_ids.id[7]==id[7]);
  125. // return (strncmp(id,other_ids.id,ID_SIZE-1) == 0);
  126. }
  127. bool operator != (char *other_id)
  128. {
  129. return !(*this == other_id);
  130. }
  131. bool operator != (IDString &other_ids)
  132. {
  133. return !(*this == other_ids);
  134. }
  135. void operator = (char *new_id)
  136. {
  137. init(new_id);
  138. }
  139. void operator = (IDString & new_ids)
  140. {
  141. init(new_ids);
  142. }
  143. bool isNull (void)
  144. {
  145. return (id[0] == 0);
  146. }
  147. void standardize (void)
  148. {
  149. strupr(id);
  150. }
  151. };
  152. //--------------------------------------------------------------------------
  153. class FullPathFileName
  154. {
  155. //Data items...
  156. //-------------
  157. private:
  158. protected:
  159. char *fullName;
  160. public:
  161. //Member functions...
  162. //-------------------
  163. private:
  164. protected:
  165. public:
  166. void init (void)
  167. {
  168. fullName = NULL;
  169. }
  170. void init (char *dir_path, const char *name, char *ext);
  171. FullPathFileName (void)
  172. {
  173. init();
  174. }
  175. FullPathFileName (char *dir_path, const char *name, char *ext)
  176. {
  177. init();
  178. init(dir_path, name, ext);
  179. }
  180. inline operator char * (void)
  181. {
  182. return fullName;
  183. }
  184. void destroy (void);
  185. void changeExt (char *from, char *to);
  186. ~FullPathFileName (void);
  187. };
  188. //---------------------------------------------------------------------------
  189. #endif
  190. //---------------------------------------------------------------------------
  191. //
  192. // Edit Log
  193. //
  194. // $Log$
  195. //
  196. //---------------------------------------------------------------------------