forked from RaptDept/ptparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchordtext.cpp
126 lines (109 loc) · 3.29 KB
/
chordtext.cpp
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/////////////////////////////////////////////////////////////////////////////
// Name: chordtext.cpp
// Purpose: Stores and renders chord text
// Author: Brad Larsen
// Modified by:
// Created: Jan 3, 2005
// RCS-ID:
// Copyright: (c) Brad Larsen
// License: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include "stdwx.h"
#include "chordtext.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Default Constants
const wxByte ChordText::DEFAULT_POSITION = 0;
// Constructor/Destructor
/// Default Constructor
ChordText::ChordText() :
m_position(DEFAULT_POSITION)
{
//------Last Checked------//
// - Jan 3, 2005
}
/// Primary Constructor
/// @param position Zero-based index of the position within the system where the
/// chord text is anchored
/// @param chordName Chord name represented in the chord text
ChordText::ChordText(wxUint32 position, const ChordName& chordName) :
m_position((wxByte)position), m_chordName(chordName)
{
//------Last Checked------//
// - Jan 3, 2005
wxASSERT(IsValidPosition(position));
}
/// Copy Constructor
ChordText::ChordText(const ChordText& chordText) :
m_position(DEFAULT_POSITION)
{
//------Last Checked------//
// - Jan 3, 2005
*this = chordText;
}
/// Destructor
ChordText::~ChordText()
{
//------Last Checked------//
// - Jan 3, 2005
}
// Operators
/// Assignment Operator
const ChordText& ChordText::operator=(const ChordText& chordText)
{
//------Last Checked------//
// - Jan 3, 2005
// Check for assignment to self
if (this != &chordText)
{
m_position = chordText.m_position;
m_chordName = chordText.m_chordName;
}
return (*this);
}
/// Equality Operator
bool ChordText::operator==(const ChordText& chordText) const
{
//------Last Checked------//
// - Jan 3, 2005
return (
(m_position == chordText.m_position) &&
(m_chordName == chordText.m_chordName)
);
}
/// Inequality Operator
bool ChordText::operator!=(const ChordText& chordText) const
{
//------Last Checked------//
// - Jan 3, 2005
return (!operator==(chordText));
}
// Serialization Functions
/// Performs serialization for the class
/// @param stream Power Tab output stream to serialize to
/// @return True if the object was serialized, false if not
bool ChordText::DoSerialize(PowerTabOutputStream& stream)
{
//------Last Checked------//
// - Jan 3, 2005
stream << m_position;
wxCHECK(stream.CheckState(), false);
m_chordName.Serialize(stream);
wxCHECK(stream.CheckState(), false);
return (stream.CheckState());
}
/// Performs deserialization for the class
/// @param stream Power Tab input stream to load from
/// @param version File version
/// @return True if the object was deserialized, false if not
bool ChordText::DoDeserialize(PowerTabInputStream& stream, wxWord version)
{
//------Last Checked------//
// - Jan 3, 2005
stream >> m_position;
wxCHECK(stream.CheckState(), false);
m_chordName.Deserialize(stream, version);
wxCHECK(stream.CheckState(), false);
return (stream.CheckState());
}