home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sources / misc / 3821 < prev    next >
Encoding:
Text File  |  1992-08-21  |  20.6 KB  |  674 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: tlhouns@srv.pacbell.com (Lee Hounshell)
  4. Subject:  v31i092:  var - a C++ string class library, Part02/02
  5. Message-ID: <1992Aug21.155040.28983@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 4bbd0505512aaef7d77793d0c8f8be7d
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v31i091=var.104945@sparky.IMD.Sterling.COM>
  11. Date: Fri, 21 Aug 1992 15:50:40 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 659
  14.  
  15. Submitted-by: tlhouns@srv.pacbell.com (Lee Hounshell)
  16. Posting-number: Volume 31, Issue 92
  17. Archive-name: var/part02
  18. Environment: C++
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then feed it
  22. # into a shell via "sh file" or similar.  To overwrite existing files,
  23. # type "sh file -c".
  24. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  25. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  26. # Contents:  Makefile Misc.C Misc.H demo.C var.H
  27. # Wrapped by kent@sparky on Fri Aug 21 10:47:45 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. echo If this archive is complete, you will see the following message:
  30. echo '          "shar: End of archive 2 (of 2)."'
  31. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'Makefile'\"
  33. else
  34.   echo shar: Extracting \"'Makefile'\" \(1102 characters\)
  35.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  36. X############################################################################
  37. X#       make - compiles the C++ library (libvar.a) 
  38. X#       make clean - removes all .o files generated in these procedures
  39. X#       make clobber - removes all libraries, cleans up .o's
  40. X############################################################################
  41. X
  42. X
  43. X# from the two below, pick the operating system closest to yours:
  44. XINCDIRS = -I.
  45. X
  46. XSYS    = SUN
  47. XCC    = CC
  48. XCFLAGS    = -O $(INCDIRS)
  49. XARFLAGS    = rv
  50. X
  51. X
  52. Xis_bsd    = test $(SYS) = SUN
  53. X
  54. Xall:    libvar.a
  55. X
  56. XC++FILES = var.C Misc.C
  57. XINS_HFILES = var.H Misc.H
  58. XHFILES   =    $(INS_HFILES)
  59. X
  60. XOBJECTS = ${C++FILES:.C=.o}
  61. X
  62. Xlibvar.a:    $(OBJECTS)
  63. X        ar $(ARFLAGS) $@ $?
  64. X        if $(is_bsd) ; then ranlib $@; fi
  65. X
  66. X$(OBJECTS):    $(HFILES)
  67. X    
  68. X
  69. Xclean:    
  70. X        rm -f *.o a.out core $(OBJECTS)
  71. X        cd demo; $(MAKE) clean
  72. X
  73. Xclobber:    clean
  74. X        rm -fr $(DOTAS)
  75. X        cd demo; $(MAKE) clobber
  76. X
  77. X#####
  78. X#####
  79. X#.SUFFIXES: .o .C .C~ .c .c~
  80. X.SUFFIXES: .o .C .C~
  81. X.C~.C:
  82. X    -cd $(<D); $(GET) $(GFLAGS) $(<F)
  83. X.C.c:
  84. X    $(CC) $(CFLAGS) -Fc $*.C > $*.c
  85. X.C.o:
  86. X    $(CC) $(CFLAGS) -c $*.C
  87. X.C~.o:
  88. X    -cd $(<D); $(GET) $(GFLAGS) $(<F)
  89. X    $(CC) $(CFLAGS) -c $*.C
  90. X
  91. END_OF_FILE
  92.   if test 1102 -ne `wc -c <'Makefile'`; then
  93.     echo shar: \"'Makefile'\" unpacked with wrong size!
  94.   fi
  95.   # end of 'Makefile'
  96. fi
  97. if test -f 'Misc.C' -a "${1}" != "-c" ; then 
  98.   echo shar: Will not clobber existing file \"'Misc.C'\"
  99. else
  100.   echo shar: Extracting \"'Misc.C'\" \(5782 characters\)
  101.   sed "s/^X//" >'Misc.C' <<'END_OF_FILE'
  102. X// 
  103. X// NAME:    MISC.C
  104. X//
  105. X// PURPOSE:    generalized functions for C++ class library routines
  106. X// AUTHOR:    Lee Hounshell
  107. X//
  108. X
  109. X#include <stdlib.h>
  110. X#include <stream.h>
  111. X#include <memory.h>
  112. X#include <string.h>
  113. X#include <ctype.h>
  114. X#include "Misc.H"
  115. X
  116. X
  117. X// =============================================================================
  118. X// stuff thet jes' be here 'cause i wuz be 2 lazy 2 done drop it sumplace else, Mazza!
  119. X// =============================================================================
  120. X
  121. X
  122. X// -----------------------------------------------------------------------------
  123. X// convert an integer into an ascii string.  return a pointer to that string.
  124. X//
  125. Xchar *itoa(const int foo)
  126. X{
  127. X    static char int_buf[28];
  128. X    sprintf(int_buf, "%d", foo);
  129. X    return int_buf;
  130. X}
  131. X
  132. X
  133. X// convert an unsigned integer into an ascii string.  return a pointer to that string.
  134. X//
  135. Xchar *uitoa(const unsigned int foo)
  136. X{
  137. X    static char int_buf[28];
  138. X    sprintf(int_buf, "%u", foo);
  139. X    return int_buf;
  140. X}
  141. X
  142. X
  143. X// convert a long into an ascii string.  return a pointer to that string.
  144. X//
  145. X#ifdef HP
  146. Xchar *ltoa(long foo)
  147. X#else
  148. Xchar *ltoa(const long foo)
  149. X#endif
  150. X{
  151. X    static char long_buf[28];
  152. X    sprintf(long_buf, "%ld", foo);
  153. X    return long_buf;
  154. X}
  155. X
  156. X
  157. X// convert an unsigned long into an ascii string.  return a pointer to that string.
  158. X//
  159. X#ifdef HP
  160. Xchar *ultoa(unsigned long foo)
  161. X#else
  162. Xchar *ultoa(const unsigned long foo)
  163. X#endif
  164. X{
  165. X    static char long_buf[28];
  166. X    sprintf(long_buf, "%lu", foo);
  167. X    return long_buf;
  168. X}
  169. X
  170. X
  171. X// convert a double into an ascii string.  return a pointer to that string.
  172. X// truncate any extra zeros after the decimal point.
  173. X//
  174. Xchar *dtoa(const double foo)
  175. X{
  176. X    static char double_buf[28];
  177. X    sprintf(double_buf, "%lf", foo);
  178. X    char *ptr;
  179. X    for (ptr = double_buf; *ptr; ++ptr) {
  180. X    if (*ptr == '.') {
  181. X        // we may need to truncate zeroes
  182. X        ptr = double_buf + (strlen(double_buf) - 1);
  183. X        while (*ptr == '0') {
  184. X        *ptr-- = 0;
  185. X        }
  186. X        if (*ptr == '.') {
  187. X        *ptr = 0;
  188. X        }
  189. X        break;
  190. X    }
  191. X    }
  192. X    return double_buf;
  193. X}
  194. X
  195. X
  196. X// convert an ascii string to a double
  197. X//
  198. Xdouble atod(char * foo)
  199. X{
  200. X    double d = 0;
  201. X    if (!foo || !*foo) {
  202. X    return d;
  203. X    }
  204. X    if (!isdigit(*foo)) {
  205. X    if (*foo != '-' && *foo != '+') {
  206. X        return d;
  207. X    }
  208. X    if (!isdigit(*(foo + 1))) {
  209. X        return d;
  210. X    }
  211. X    }
  212. X    sscanf(foo, "%lf", &d);
  213. X    return d;
  214. X}
  215. X
  216. X// -----------------------------------------------------------------------------
  217. X
  218. X// convert a 24-hour time (hhmm) into LMOS string format (hhmmZ - where Z is 'A' or 'P')
  219. X//
  220. Xchar *ltoTime(const long date24)
  221. X{
  222. X    static char time_buf[6];
  223. X    *time_buf = 0;
  224. X    if (date24 != 0L) {
  225. X    long minute = date24 % 100;
  226. X    long hour = (date24 - minute) / 100;
  227. X    char ampm = 'A';
  228. X    if (hour >= 12) {
  229. X        ampm = 'P';
  230. X        if (hour > 12) hour -= 12;
  231. X    }
  232. X    sprintf(time_buf, "%02d%02d%c", hour, minute, ampm);
  233. X    return time_buf;
  234. X    }
  235. X}
  236. X
  237. X
  238. X// -----------------------------------------------------------------------------
  239. X// scan input until the desired character is found
  240. X//
  241. Xistream & look_for(istream &in, char c)
  242. X{
  243. X    int input = 0;
  244. X    if (getenv("INPUT_DEBUG") != NULL) {
  245. X    cerr << "Debug: looking for input character '" << c << "'" << endl;
  246. X    }
  247. X    while (input != c && input != EOF) {
  248. X    input = in.get();
  249. X    if (getenv("INPUT_DEBUG") != NULL) {
  250. X        cerr << input;
  251. X    }
  252. X    }
  253. X    return in;
  254. X}
  255. X
  256. X
  257. X// -----------------------------------------------------------------------------
  258. X// this function is used by lots of other classes for I/O, also.
  259. X// it really is a sort of "general-purpose," non-class-specific routine
  260. X// i use it for extracting class memebers from a saved object
  261. X//
  262. Xvoid scan_string(istream &in, char *ptr, int size)
  263. X{
  264. X    char buffer[3];
  265. X    char *input;
  266. X    if (size) --size;
  267. X    if (getenv("INPUT_DEBUG") != NULL) {
  268. X    cerr << "Debug: scanning for string (length=" << size << ")" << endl;
  269. X    }
  270. X    if (ptr != NULL) {
  271. X    input = ptr;
  272. X    }
  273. X    else {
  274. X    input = buffer;
  275. X    }
  276. X    *input = 0;
  277. X    look_for(in, '\'');                // find first quote
  278. X    int endflag = 0;
  279. X    int count = 0;
  280. X    while (1) {
  281. X    int ch;
  282. X    if ((ch = in.get()) == EOF) {
  283. X        if (getenv("INPUT_DEBUG") != NULL) {
  284. X        cerr << "debug: scan_string(): unexpected EOF found" << endl;
  285. X        }
  286. X        *input = 0;
  287. X        break;
  288. X    }
  289. X    *input = ch;
  290. X    if (getenv("INPUT_DEBUG") != NULL) {
  291. X        cerr << *input;
  292. X    }
  293. X    if (*input == '\n' && endflag) {    // all done!
  294. X        *input = 0;
  295. X        if (getenv("INPUT_DEBUG") != NULL) {
  296. X        cerr << "\nDebug: scan_string() found: '" << ptr << "'" << endl;
  297. X        }
  298. X        break;                // found end of string
  299. X    }
  300. X    if (count >= size) {            // string is too big for buffer
  301. X        if (getenv("INPUT_DEBUG") != NULL) {
  302. X        cerr << "\nDebug: scan_string() size exceeded - truncating string" << endl;
  303. X        }
  304. X        if (ch != '\'') {
  305. X        look_for(in, '\'');        // skip to last quote
  306. X        }
  307. X        endflag = 1;
  308. X        continue;
  309. X    }
  310. X    if (ptr != NULL && endflag) {        // possibly found end of string
  311. X        *(input+1) = *input;
  312. X        *input = '\'';
  313. X        ++input;
  314. X        ++count;
  315. X    }
  316. X    if ((endflag = (*input == '\'')) == 0) {// got a close quote??
  317. X        if (*ptr) ++input;
  318. X        ++count;
  319. X    }
  320. X    }
  321. X}
  322. X
  323. X
  324. X// these functions are also used by other classes for I/O.
  325. X// they keep track of "indent" levels for printing objects with inheritance
  326. X
  327. Xstatic int no_tab_stops = 0;
  328. X
  329. X
  330. X// -----------------------------------------------------------------------------
  331. X//
  332. Xostream & Tab(ostream &out)
  333. X{
  334. X    out << "\n";
  335. X    for (int i = 0; i < no_tab_stops; ++i) {
  336. X    out << "    ";                // really one-half a tab stop
  337. X    }
  338. X    return out;
  339. X}
  340. X
  341. X
  342. X// -----------------------------------------------------------------------------
  343. X//
  344. Xostream & Inc(ostream &out)
  345. X{
  346. X    ++no_tab_stops;
  347. X    return Tab(out);
  348. X}
  349. X
  350. X
  351. X// -----------------------------------------------------------------------------
  352. X//
  353. Xostream & Dec(ostream &out)
  354. X{
  355. X    --no_tab_stops;
  356. X    return Tab(out);
  357. X}
  358. X
  359. END_OF_FILE
  360.   if test 5782 -ne `wc -c <'Misc.C'`; then
  361.     echo shar: \"'Misc.C'\" unpacked with wrong size!
  362.   fi
  363.   # end of 'Misc.C'
  364. fi
  365. if test -f 'Misc.H' -a "${1}" != "-c" ; then 
  366.   echo shar: Will not clobber existing file \"'Misc.H'\"
  367. else
  368.   echo shar: Extracting \"'Misc.H'\" \(712 characters\)
  369.   sed "s/^X//" >'Misc.H' <<'END_OF_FILE'
  370. X// 
  371. X// NAME:    MISC.H
  372. X//
  373. X// PURPOSE:    generalized functions for C++ class library routines
  374. X// AUTHOR:    Lee Hounshell
  375. X//
  376. X
  377. X#ifndef MISC_H
  378. X#define MISC_H
  379. X
  380. X#include <stream.h>
  381. X
  382. X    char *itoa(const int foo);
  383. X    char *uitoa(const unsigned int foo);
  384. X
  385. X#ifdef HP
  386. X    char *ltoa(long foo);
  387. X    char *ultoa(unsigned long foo);
  388. X#else
  389. X    char *ltoa(const long foo);
  390. X    char *ultoa(const unsigned long foo);
  391. X#endif
  392. X
  393. X    char *dtoa(const double foo);
  394. X    double atod(char * foo);
  395. X    char *ltoTime(const long date24);
  396. X    istream & look_for(istream &in, char c);
  397. X    void scan_string(istream &in, char *ptr, int size);
  398. X    ostream & Tab(ostream &out);
  399. X    ostream & Inc(ostream &out);
  400. X    ostream & Dec(ostream &out);
  401. X
  402. X#endif
  403. X
  404. END_OF_FILE
  405.   if test 712 -ne `wc -c <'Misc.H'`; then
  406.     echo shar: \"'Misc.H'\" unpacked with wrong size!
  407.   fi
  408.   # end of 'Misc.H'
  409. fi
  410. if test -f 'demo.C' -a "${1}" != "-c" ; then 
  411.   echo shar: Will not clobber existing file \"'demo.C'\"
  412. else
  413.   echo shar: Extracting \"'demo.C'\" \(815 characters\)
  414.   sed "s/^X//" >'demo.C' <<'END_OF_FILE'
  415. X#include    <stdlib.h>
  416. X#include    <stream.h>
  417. X#include    <var.H>
  418. X
  419. Xmain ()
  420. X{
  421. X    var value;                // declare an "untyped" var
  422. X    value = "hello world";            // initialize it
  423. X    cout << value << endl;            // output "hello world"
  424. X    value = value(3, value.length() - 6);    // substring example
  425. X    cout << value << endl;            // output "lo wo"
  426. X    value = 35;                // assignment of int
  427. X    value += 42.375;            // add 42.375 to present value
  428. X    cout << value << endl;            // output "77.375"
  429. X    cout << value.format("formatted output example %05d of value") << endl;
  430. X    cout << value.format("multiple outputs #1=%d, #2=%9.2f of value") << endl;
  431. X    value.null(2);                // truncate string
  432. X    value += " sunset strip";        // concatenate a string
  433. X    cout << value.format("%s") << endl;    // output "77 sunset strip"
  434. X    cout << value[3] << value[4] << value[5] << endl; // output "sun"
  435. X}
  436. X
  437. END_OF_FILE
  438.   if test 815 -ne `wc -c <'demo.C'`; then
  439.     echo shar: \"'demo.C'\" unpacked with wrong size!
  440.   fi
  441.   # end of 'demo.C'
  442. fi
  443. if test -f 'var.H' -a "${1}" != "-c" ; then 
  444.   echo shar: Will not clobber existing file \"'var.H'\"
  445. else
  446.   echo shar: Extracting \"'var.H'\" \(8731 characters\)
  447.   sed "s/^X//" >'var.H' <<'END_OF_FILE'
  448. X//
  449. X// NAME:    var.H
  450. X//
  451. X// PURPOSE:    C++ Generic "Universal Variable" Class Library Header File
  452. X// AUTHOR:    Lee Hounshell
  453. X//
  454. X
  455. X#ifndef VAR_H
  456. X#define VAR_H
  457. X
  458. X#include    "string.h"
  459. X
  460. X// -----------------------------------------------------------------------------
  461. X//
  462. Xclass varsize {
  463. X    // dummy class needed for var constructor of specific size that
  464. X    // doesn't conflict with the var integer type constructor
  465. X    public:
  466. X    // Constructors & Destructors
  467. X    varsize(int sz);                // constructor
  468. X    int size;                    // size of var
  469. X};
  470. X
  471. Xclass subvar;
  472. X
  473. X// -----------------------------------------------------------------------------
  474. X//
  475. Xclass var {
  476. X
  477. X    public:
  478. X    // Standard Interface
  479. X    const var & type(void) const;            // who am i
  480. X
  481. X    // Constructors & Destructors
  482. X    var(void);                    // constructor
  483. X    var(const varsize &);                // constructor
  484. X    var(const char *);                // constructor
  485. X    var(const char);                // constructor
  486. X    var(const short);                // constructor
  487. X    var(const unsigned short);            // constructor
  488. X    var(const int);                    // constructor
  489. X    var(const unsigned int);            // constructor
  490. X    var(const long);                // constructor
  491. X    var(const unsigned long);            // constructor
  492. X    var(const double);                // constructor
  493. X    var(const var &);                // copy constructor
  494. X    ~var(void);                    // destructor
  495. X
  496. X    // Operators
  497. X    var & operator = (const char *);        // assignment
  498. X        var & operator = (const var &);            // assignment
  499. X        char & operator [] (const int);            // indexing
  500. X        subvar & operator () (int, int) const;        // substring
  501. X        subvar & operator () (const int) const;        // substring
  502. X        friend ostream & operator << (ostream &, const var &); // output
  503. X        friend istream & operator >> (istream &, var &); // input
  504. X    friend class subvar;                // substring
  505. X
  506. X    // More Operators (used for arithmetic type extension)
  507. X    var & operator = (const char);            // assignment
  508. X    var & operator = (const short);            // assignment
  509. X    var & operator = (const unsigned short);    // assignment
  510. X    var & operator = (const int);            // assignment
  511. X    var & operator = (const unsigned int);        // assignment
  512. X    var & operator = (const long);            // assignment
  513. X    var & operator = (const unsigned long);        // assignment
  514. X    var & operator = (const double);        // assignment
  515. X
  516. X    // Casting Operators
  517. X    operator char * (void) const;            // type conversion
  518. X    operator double (void) const;            // type conversion
  519. X
  520. X    // Assignment Operators
  521. X        var & operator ++ (void);            // increment (pre-index only)
  522. X        var & operator -- (void);            // decrement (pre-index only)
  523. X        var operator ! (void) const;            // not
  524. X
  525. X        var operator + (const var &) const;        // addition OR concatenation
  526. X        var operator - (const var &) const;        // subtraction
  527. X        var operator * (const var &) const;        // multiplication
  528. X        var operator / (const var &) const;        // division
  529. X        var operator % (const var &) const;        // remainder
  530. X
  531. X        var & operator += (const var &);        // addition OR concatenation
  532. X        var & operator -= (const var &);        // subtraction
  533. X        var & operator *= (const var &);        // multiplication
  534. X        var & operator /= (const var &);        // division
  535. X        var & operator %= (const var &);        // remainder
  536. X
  537. X        var & operator += (const char &);        // addition OR concatenation
  538. X        var & operator += (const char *);        // addition OR concatenation
  539. X        var & operator -= (const char *);        // subtraction
  540. X        var & operator *= (const char *);        // multiplication
  541. X        var & operator /= (const char *);        // division
  542. X        var & operator %= (const char *);        // remainder
  543. X
  544. X        var & operator += (const double);        // addition OR concatenation
  545. X        var & operator -= (const double);        // subtraction
  546. X        var & operator *= (const double);        // multiplication
  547. X        var & operator /= (const double);        // division
  548. X        var & operator %= (const double);        // remainder
  549. X
  550. X    friend var operator + (const char *, const var &); // addition OR concatenation
  551. X    friend var operator - (const char *, const var &); // subtraction
  552. X    friend var operator * (const char *, const var &); // multiplication
  553. X    friend var operator / (const char *, const var &); // division
  554. X    friend var operator % (const char *, const var &); // remainder
  555. X    friend var operator + (const var &, const char *); // addition OR concatenation
  556. X    friend var operator - (const var &, const char *); // subtraction
  557. X    friend var operator * (const var &, const char *); // multiplication
  558. X    friend var operator / (const var &, const char *); // division
  559. X    friend var operator % (const var &, const char *); // remainder
  560. X
  561. X    friend var operator + (const var &, const double); // addition OR concatenation
  562. X    friend var operator - (const var &, const double); // subtraction
  563. X    friend var operator * (const var &, const double); // multiplication
  564. X    friend var operator / (const var &, const double); // division
  565. X    friend var operator % (const var &, const double); // remainder
  566. X    friend var operator + (const double, const var &); // addition OR concatenation
  567. X    friend var operator - (const double, const var &); // subtraction
  568. X    friend var operator * (const double, const var &); // multiplication
  569. X    friend var operator / (const double, const var &); // division
  570. X    friend var operator % (const double, const var &); // remainder
  571. X
  572. X    // Equality Operators
  573. X        int operator == (const var &) const;        // equality
  574. X        int operator != (const var &) const;        // inequality
  575. X        int operator < (const var &) const;        // less than
  576. X        int operator > (const var &) const;        // greater than
  577. X        int operator <= (const var &) const;        // less than or equal
  578. X        int operator >= (const var &) const;        // greater than or equal
  579. X
  580. X    friend int operator == (const var &, const char *); // equality
  581. X    friend int operator != (const var &, const char *); // inequality
  582. X    friend int operator < (const var &, const char *);  // less than
  583. X    friend int operator > (const var &, const char *);  // greater than
  584. X    friend int operator <= (const var &, const char *); // less than or equal
  585. X    friend int operator >= (const var &, const char *); // greater than or equal
  586. X    friend int operator == (const char *, const var &); // equality
  587. X    friend int operator != (const char *, const var &); // inequality
  588. X    friend int operator < (const char *, const var &);  // less than
  589. X    friend int operator > (const char *, const var &);  // greater than
  590. X    friend int operator <= (const char *, const var &); // less than or equal
  591. X    friend int operator >= (const char *, const var &); // greater than or equal
  592. X
  593. X    friend int operator == (const var &, const double); // equality
  594. X    friend int operator != (const var &, const double); // inequality
  595. X    friend int operator < (const var &, const double);  // less than
  596. X    friend int operator > (const var &, const double);  // greater than
  597. X    friend int operator <= (const var &, const double); // less than or equal
  598. X    friend int operator >= (const var &, const double); // greater than or equal
  599. X    friend int operator == (const double, const var &); // equality
  600. X    friend int operator != (const double, const var &); // inequality
  601. X    friend int operator < (const double, const var &);  // less than
  602. X    friend int operator > (const double, const var &);  // greater than
  603. X    friend int operator <= (const double, const var &); // less than or equal
  604. X    friend int operator >= (const double, const var &); // greater than or equal
  605. X
  606. X    // Custom Interface
  607. X    void null(int);                    // "null" out string
  608. X    void changesize(int);                // change allocated memory
  609. X    int length(void) const;                // length of string
  610. X    const char * vartype(void) const;        // name of this var type
  611. X    void change_type(const char *);            // change var type
  612. X    int is_string(void) const;            // test var type
  613. X    int is_double(void) const;            // test var type
  614. X    int is_long(void) const;            // test var type
  615. X    int strchr(const char) const;            // strchr(char) index
  616. X    int strrchr(const char) const;            // strrchr(char) index
  617. X    var & concat(const var &);            // concatenation
  618. X    var & format(const char *);            // set output format
  619. X    void print(ostream &) const;            // output
  620. X    void read(istream &);                // input
  621. X
  622. X    static int save_me;                // cntrl object input
  623. X    static int save_it(const int save_flag = var::save_me); // input ctrl
  624. X
  625. X    protected:
  626. X
  627. X    private:
  628. X    int    numcheck(const char *) const;        // determine is_numeric value
  629. X
  630. X    static    const var ctype;            // for type() function
  631. X    short    fixed;                    // 1=fixed data type
  632. X    short    is_numeric;                // 0=string, 1=short/int/long, 2=float/double
  633. X    int    data_str_len;                // length of allocated "string"
  634. X    int    data_str_end;                // index to current "end" of string
  635. X    char    *data_str;                // for "string" data
  636. X    char    *format_str;                // the input/output format string
  637. X
  638. X};
  639. X
  640. X
  641. Xclass subvar : public var {
  642. X    public:
  643. X        var & operator = (const var &);            // substring replacement
  644. X    var        *varptr;
  645. X    unsigned    offset;
  646. X    unsigned    length;
  647. X};
  648. X
  649. X#endif
  650. X
  651. END_OF_FILE
  652.   if test 8731 -ne `wc -c <'var.H'`; then
  653.     echo shar: \"'var.H'\" unpacked with wrong size!
  654.   fi
  655.   # end of 'var.H'
  656. fi
  657. echo shar: End of archive 2 \(of 2\).
  658. cp /dev/null ark2isdone
  659. MISSING=""
  660. for I in 1 2 ; do
  661.     if test ! -f ark${I}isdone ; then
  662.     MISSING="${MISSING} ${I}"
  663.     fi
  664. done
  665. if test "${MISSING}" = "" ; then
  666.     echo You have unpacked both archives.
  667.     rm -f ark[1-9]isdone
  668. else
  669.     echo You still must unpack the following archives:
  670.     echo "        " ${MISSING}
  671. fi
  672. exit 0
  673. exit 0 # Just in case...
  674.