forked from peterkvt80/vbit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttxline.h
98 lines (78 loc) · 3.14 KB
/
ttxline.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef TTXLINE_H
#define TTXLINE_H
#include <iostream>
#include <iomanip>
#include <string>
#include "ttxcodes.h"
/** TTXLine - a single line of teletext
* The line is always stored in 40 bytes in transmission ready format
* (but with the parity bit set to 0).
*/
class TTXLine
{
public:
/** Constructors */
TTXLine();
TTXLine(std::string const& line, bool validate=true);
// TTXLine(std::string const& line);
/** Default destructor */
virtual ~TTXLine();
/** Set the teletext line contents
* \param val - New value to set
* \param validateLine - If true, it ensures the line is checked and modified if needed to be transmission ready.
*/
void Setm_textline(std::string const& val, bool validateLine=true);
/** Access m_textline
* \return The current value of m_textline
*/
std::string GetLine();
/** True if the line is double height
* @todo This is not good enough. Need to know the state at a particular point on a line. Add a character position parameter.
*/
bool IsDoubleHeight();
/**
* @brief Check if the line is blank so that we don't bother to write it to the file.
* @return true is the line is blank
*/
bool IsBlank();
/** Place a character in a line. Must be an actual teletext code.
* Bit 7 will be stripped off.
* @param x - Address of the character
& @param code - The character to set
* \return previous character at that location (for undo)
*/
char SetCharAt(int x,int code);
/** Get one character from this line.
* If there is no data set then return a space
*/
char GetCharAt(int xLoc);
/** Return the line with control codes mapped for writing to a file
* \return The mapped line
*/
std::string GetMappedline();
/** GetMappedLine7bit - returns a string with text file-safe mappings applied.
* Escape to 7 bit (required by Javascript Droidfax)
*/
std::string GetMappedline7bit();
/** Determine if a location on the line is in alpha or graphics mode
* \param loc The column address to look at
* \return true if the character position at loc is in an alpha context
*/
bool IsAlphaMode(int loc);
/** Adds line to a linked list
* This is used for enhanced packets which might require multiples of the same row
*/
void AppendLine(std::string const& line);
TTXLine* GetNextLine(){return _nextLine;}
void Dump();
bool GetChanged(){bool temp=_changed;_changed=false;return temp;}; /// Get the changed status (and clear the flag)
protected:
private:
std::string validate(std::string const& test);
std::string m_textline;
TTXLine* _nextLine; // @todo probably not used. We can dump this
// If SetLine or SetChar can set the changed flag.
// The changed flag is used to set the C8 flag and then is reset.
bool _changed; /// If the line contents has changed. Set by SetLine or SetChar
};
#endif // TTXLINE_H