📄 datalog.cpp
字号:
//: C18:Datalog.cpp {O}
// From Thinking in C++, 2nd Edition
// Available 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::getTime() { return time; }
void DataPoint::setTime(tm t) { time = t; }
const char* DataPoint::getLatitude() {
return latitude;
}
void DataPoint::setLatitude(const char* l) {
latitude[bsz - 1] = 0;
strncpy(latitude, l, bsz - 1);
}
const char* DataPoint::getLongitude() {
return longitude;
}
void DataPoint::setLongitude(const char* l) {
longitude[bsz - 1] = 0;
strncpy(longitude, l, bsz - 1);
}
double DataPoint::getDepth() { return depth; }
void DataPoint::setDepth(double d) { depth = d; }
double DataPoint::getTemperature() {
return temperature;
}
void DataPoint::setTemperature(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) << getTime().tm_mon << '\\'
<< setw(2) << getTime().tm_mday << '\\'
<< setw(2) << getTime().tm_year << ' '
<< setw(2) << getTime().tm_hour << ':'
<< setw(2) << getTime().tm_min << ':'
<< setw(2) << getTime().tm_sec;
os.fill(' '); // Pad on left with ' '
os << " Lat:" << setw(9) << getLatitude()
<< ", Long:" << setw(9) << getLongitude()
<< ", depth:" << setw(9) << getDepth()
<< ", temp:" << setw(9) << getTemperature()
<< endl;
} ///:~
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -