📄 datalog.cpp
字号:
//: C19:Datalog.cpp {O}
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Datapoint member functions
#include "DataLogger.h"
#include <iomanip>
#include <cstring>
using namespace std;
tm DataPoint::Time() { return Tm; }
void DataPoint::Time(tm t) { Tm = t; }
const char* DataPoint::latitude() {
return Latitude;
}
void DataPoint::latitude(const char* l) {
Latitude[bsz - 1] = 0;
strncpy(Latitude, l, bsz - 1);
}
const char* DataPoint::longitude() {
return Longitude;
}
void DataPoint::longitude(const char* l) {
Longitude[bsz - 1] = 0;
strncpy(Longitude, l, bsz - 1);
}
double DataPoint::depth() { return Depth; }
void DataPoint::depth(double d) { Depth = d; }
double DataPoint::temperature() {
return Temperature;
}
void DataPoint::temperature(double t) {
Temperature = t;
}
void DataPoint::print(ostream& os) {
os.setf(ios::fixed, ios::floatfield);
os.precision(4);
os.fill('0'); // Pad on left with '0'
os << setw(2) << Time().tm_mon << '\\'
<< setw(2) << Time().tm_mday << '\\'
<< setw(2) << Time().tm_year << ' '
<< setw(2) << Time().tm_hour << ':'
<< setw(2) << Time().tm_min << ':'
<< setw(2) << Time().tm_sec;
os.fill(' '); // Pad on left with ' '
os << " Lat:" << setw(9) << latitude()
<< ", Long:" << setw(9) << longitude()
<< ", depth:" << setw(9) << depth()
<< ", temp:" << setw(9) << temperature()
<< endl;
} ///:~
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -