📄 hwrecordc.hh
字号:
/**************************************************************** Description:This module allows HWHeaderC and HWRecordC objects to be read andwritten to/from the C++ stream objects. Return characters areautomatically appended to the output line. Examples: ifstream F("hello.hw", ios::in || ios::nocreate); HWHeaderC Header; F >> Header; HWRecordC Rec1, Rec2; F >> Rec1 >> Rec2; ofstream F("hello.hw", ios::out); HWHeaderC Header; strcpy(Header.String, "hello"); F << Header; while (<not done reading user input>) { HWRecordC Rec; <get input point from user into Rec> F << Rec; }****************************************************************/#include <fstream.h>#include <string.h>struct HWHeaderC { HWHeaderC() { strcpy(Magic, "HW_file"); strcpy(String, ""); } IsValid() {return strcmp(Magic, "HW_file") == 0;} // A magic string. char Magic[20]; // The letter, word, or string written in the file. An // empty string if it is unknown. char String[80];};// If unknown, XTilt, YTilt, and Pressure can be filled with the value -1.// XPos and YPos must be non-negative.struct DataPointC { DataPointC() { XPos = YPos = 0; XTilt = YTilt = Pressure = -1; } // The co-ordinates of the point in any units. Must // be positive. long XPos, YPos; // Stylus tilt in degrees along the X and Y axis. // This record would be unused by // the digitizing tablet we have, but could be faked or // used by other digitizing tablets. long XTilt, YTilt; // Pressure or width of the pen stroke in some units. long Pressure;};struct HWRecordC { HWRecordC() { Type = Time = 0; } // The "type" of the record. // 0 = A data record. // 1 = A pen down event. // 2 = A pen up event. // 3 = A character boundary. // 4 = A word boundary. // 5 = End of file (EOF). int Type; // The time, in ms, between the first record in the file // and this record. long Time; // If type == 0, then this is the data point of the data record. DataPointC DataPoint;};ostream& operator << (ostream& outfile, HWHeaderC Header);ostream& operator << (ostream& outfile, HWRecordC Record);istream& operator >> (istream& infile, HWHeaderC& Header);istream& operator >> (istream& infile, HWRecordC& Record);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -