home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C18 / Datalog.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  1.6 KB  |  63 lines

  1. //: C18:Datalog.cpp {O}
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Datapoint member functions
  7. #include "DataLogger.h"
  8. #include <iomanip>
  9. #include <cstring>
  10. using namespace std;
  11.  
  12. tm DataPoint::getTime() { return time; }
  13.  
  14. void DataPoint::setTime(tm t) { time = t; }
  15.  
  16. const char* DataPoint::getLatitude() {
  17.   return latitude;
  18. }
  19.  
  20. void DataPoint::setLatitude(const char* l) {
  21.   latitude[bsz - 1] = 0;
  22.   strncpy(latitude, l, bsz - 1);
  23. }
  24.  
  25. const char* DataPoint::getLongitude() {
  26.   return longitude;
  27. }
  28.  
  29. void DataPoint::setLongitude(const char* l) {
  30.   longitude[bsz - 1] = 0;
  31.   strncpy(longitude, l, bsz - 1);
  32. }
  33.  
  34. double DataPoint::getDepth() { return depth; }
  35.  
  36. void DataPoint::setDepth(double d) { depth = d; }
  37.  
  38. double DataPoint::getTemperature() {
  39.   return temperature;
  40. }
  41.  
  42. void DataPoint::setTemperature(double t) {
  43.   temperature = t;
  44. }
  45.  
  46. void DataPoint::print(ostream& os) {
  47.   os.setf(ios::fixed, ios::floatfield);
  48.   os.precision(4);
  49.   os.fill('0'); // Pad on left with '0'
  50.   os << setw(2) << getTime().tm_mon << '\\'
  51.      << setw(2) << getTime().tm_mday << '\\'
  52.      << setw(2) << getTime().tm_year << ' '
  53.      << setw(2) << getTime().tm_hour << ':'
  54.      << setw(2) << getTime().tm_min << ':'
  55.      << setw(2) << getTime().tm_sec;
  56.   os.fill(' '); // Pad on left with ' '
  57.   os << " Lat:" << setw(9) << getLatitude()
  58.      << ", Long:" << setw(9) << getLongitude()
  59.      << ", depth:" << setw(9) << getDepth()
  60.      << ", temp:" << setw(9) << getTemperature()
  61.      << endl;
  62. } ///:~
  63.