Skip to content

Commit 636a2b4

Browse files
committed
Removing a whole lot of warnings from clang on Windows
1 parent 5fec0af commit 636a2b4

18 files changed

+178
-172
lines changed

Src/DasherCore/AlphabetManager.cpp

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "FileWordGenerator.h"
3434

3535
#include <vector>
36-
#include <sstream>
3736

3837
using namespace Dasher;
3938

@@ -51,32 +50,30 @@ CAlphabetManager::CAlphabetManager(CSettingsStore *pSettingsStore, CDasherInterf
5150
{
5251
m_pSettingsStore->OnPreParameterChange.Subscribe(this, [this](Parameter parameter, const std::variant<bool, long, std::string>& newValue)
5352
{
54-
switch(parameter) {
55-
case SP_ALPHABET_ID:
56-
const std::string value = std::get<std::string>(newValue);
57-
// Cycle the alphabet history
58-
std::vector<std::string> newHistory;
59-
newHistory.push_back(m_pSettingsStore->GetStringParameter(SP_ALPHABET_ID));
60-
std::string v;
61-
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_1)) != value)
62-
newHistory.push_back(v);
63-
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_2)) != value)
64-
newHistory.push_back(v);
65-
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_3)) != value)
66-
newHistory.push_back(v);
67-
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_4)) != value)
68-
newHistory.push_back(v);
69-
70-
// Fill empty slots.
71-
while (newHistory.size() < 4)
72-
newHistory.push_back("");
73-
74-
m_pSettingsStore->SetStringParameter(SP_ALPHABET_1, newHistory[0]);
75-
m_pSettingsStore->SetStringParameter(SP_ALPHABET_2, newHistory[1]);
76-
m_pSettingsStore->SetStringParameter(SP_ALPHABET_3, newHistory[2]);
77-
m_pSettingsStore->SetStringParameter(SP_ALPHABET_4, newHistory[3]);
78-
break;
79-
}
53+
if(parameter == SP_ALPHABET_ID){
54+
const std::string value = std::get<std::string>(newValue);
55+
// Cycle the alphabet history
56+
std::vector<std::string> newHistory;
57+
newHistory.push_back(m_pSettingsStore->GetStringParameter(SP_ALPHABET_ID));
58+
std::string v;
59+
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_1)) != value)
60+
newHistory.push_back(v);
61+
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_2)) != value)
62+
newHistory.push_back(v);
63+
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_3)) != value)
64+
newHistory.push_back(v);
65+
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_4)) != value)
66+
newHistory.push_back(v);
67+
68+
// Fill empty slots.
69+
while (newHistory.size() < 4)
70+
newHistory.push_back("");
71+
72+
m_pSettingsStore->SetStringParameter(SP_ALPHABET_1, newHistory[0]);
73+
m_pSettingsStore->SetStringParameter(SP_ALPHABET_2, newHistory[1]);
74+
m_pSettingsStore->SetStringParameter(SP_ALPHABET_3, newHistory[2]);
75+
m_pSettingsStore->SetStringParameter(SP_ALPHABET_4, newHistory[3]);
76+
}
8077
});
8178
}
8279

Src/DasherCore/AlphabetManager.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace Dasher {
6666
CNodeManager* mgr() const override;
6767
///Rebuilds this node's parent by recreating the previous 'root' node,
6868
/// then calling RebuildForwardsFromAncestor
69-
CDasherNode *RebuildParent();
69+
CDasherNode *RebuildParent() override;
7070
///Called to build a symbol (leaf) node which is a descendant of the symbol or root node preceding this.
7171
/// Default implementation just calls the manager's CreateSymbolNode method to create a new node,
7272
/// but subclasses can override to graft themselves into the appropriate point beneath the previous node.
@@ -164,11 +164,11 @@ namespace Dasher {
164164
/// Uniquely, a paragraph symbol can enter two distinct unicode characters
165165
/// (i.e. '\r' and '\n'); every other symbol enters only a single
166166
/// unicode char, even if that might take >1 octet.
167-
int numChars();
167+
int numChars() override;
168168
void TrainSymbol();
169169
void UntrainSymbol();
170170
///Override: true iff pGroup encloses this symbol (according to its start/end symbol#)
171-
bool isInGroup(const SGroupInfo *pGroup);
171+
bool isInGroup(const SGroupInfo *pGroup) override;
172172

173173
public:
174174
double SpeedMul() override;
@@ -182,20 +182,20 @@ namespace Dasher {
182182
CGroupNode(int iOffset, CDasherScreen::Label* pLabel, CAlphabetManager* pMgr, const SGroupInfo* pGroup);
183183

184184
///Override: if m_pGroup==NULL, i.e. whole/root-of alphabet, cannot rebuild.
185-
virtual CDasherNode *RebuildParent();
185+
virtual CDasherNode *RebuildParent() override;
186186

187187
///Create children of this group node, by traversing the section of the alphabet
188188
/// indicated by m_pGroup.
189-
virtual void PopulateChildren();
190-
virtual int ExpectedNumChildren();
189+
virtual void PopulateChildren() override;
190+
virtual int ExpectedNumChildren() override;
191191

192-
virtual bool GameSearchNode(symbol sym);
193-
std::vector<unsigned int> *GetProbInfo();
192+
virtual bool GameSearchNode(symbol sym) override;
193+
std::vector<unsigned int> *GetProbInfo() override;
194194
///Override: if the group to create is the same as this node's group, return this node instead of creating a new one
195-
virtual CDasherNode *RebuildGroup(CAlphNode* pParent, const SGroupInfo* pInfo);
195+
virtual CDasherNode *RebuildGroup(CAlphNode* pParent, const SGroupInfo* pInfo) override;
196196
protected:
197197
///Override: true if pGroup encloses this one (by start/end symbol#)
198-
bool isInGroup(const SGroupInfo *pGroup);
198+
bool isInGroup(const SGroupInfo *pGroup) override;
199199

200200
public:
201201
const ColorPalette::Color& getLabelColor(const ColorPalette* colorPalette) override;

Src/DasherCore/ConversionManager.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,33 +81,33 @@ namespace Dasher {
8181

8282
class CConvNode : public CDasherNode {
8383
public:
84-
CConversionManager *mgr() const {return m_pMgr;}
84+
CConversionManager *mgr() const override {return m_pMgr;}
8585
CConvNode(int iOffset, CDasherScreen::Label *pLabel, CConversionManager *pMgr);
8686
///
8787
/// Provide children for the supplied node
8888
///
8989

90-
virtual void PopulateChildren();
91-
virtual int ExpectedNumChildren();
92-
virtual void SetFlag(int iFlag, bool bValue);
90+
virtual void PopulateChildren() override;
91+
virtual int ExpectedNumChildren() override;
92+
virtual void SetFlag(int iFlag, bool bValue) override;
9393

9494
virtual ~CConvNode();
9595

9696
///Attempts to fill vContextSymbols with the context that would exist _after_ this node has been entered
97-
void GetContext(CDasherInterfaceBase *pInterface, const CAlphabetMap *pAlphabetMap, std::vector<symbol> &vContextSymbols, int iOffset, int iLength);
97+
void GetContext(CDasherInterfaceBase *pInterface, const CAlphabetMap *pAlphabetMap, std::vector<symbol> &vContextSymbols, int iOffset, int iLength) override;
9898

9999
///
100100
/// Called whenever a node belonging to this manager first
101101
/// moves under the crosshair
102102
///
103103

104-
virtual void Do();
104+
virtual void Do() override;
105105

106106
///
107107
/// Called when a node is left backwards
108108
///
109109

110-
virtual void Undo();
110+
virtual void Undo() override;
111111
const ColorPalette::Color& getLabelColor(const ColorPalette* colorPalette) override;
112112
const ColorPalette::Color& getOutlineColor(const ColorPalette* colorPalette) override;
113113
const ColorPalette::Color& getNodeColor(const ColorPalette* colorPalette) override;

Src/DasherCore/DasherButtons.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "DasherButtons.h"
77
#include "DasherScreen.h"
88
#include "DasherInterfaceBase.h"
9-
#include <valarray>
109

1110

1211
using namespace Dasher;
@@ -31,21 +30,22 @@ void CDasherButtons::KeyDown(unsigned long iTime, Keys::VirtualKey Key, CDasherV
3130

3231
if(m_bMenu) {
3332
switch(Key) {
34-
case Keys::Button_1:
35-
case Keys::Button_4:
36-
m_bDecorationChanged = true;
37-
++iActiveBox;
38-
if(iActiveBox == m_iNumBoxes)
39-
iActiveBox = 0;
40-
break;
41-
case Keys::Button_2:
42-
case Keys::Button_3:
43-
case Keys::Primary_Input:
44-
m_bDecorationChanged = true;
45-
ScheduleZoom(pModel, m_pBoxes[iActiveBox].iTop, m_pBoxes[iActiveBox].iBottom);
46-
if(iActiveBox != m_iNumBoxes-1)
47-
iActiveBox = 0;
48-
break;
33+
case Keys::Button_1:
34+
case Keys::Button_4:
35+
m_bDecorationChanged = true;
36+
++iActiveBox;
37+
if(iActiveBox == m_iNumBoxes)
38+
iActiveBox = 0;
39+
break;
40+
case Keys::Button_2:
41+
case Keys::Button_3:
42+
case Keys::Primary_Input:
43+
m_bDecorationChanged = true;
44+
ScheduleZoom(pModel, m_pBoxes[iActiveBox].iTop, m_pBoxes[iActiveBox].iBottom);
45+
if(iActiveBox != m_iNumBoxes-1)
46+
iActiveBox = 0;
47+
break;
48+
default: break;
4949
}
5050
}
5151
else {
@@ -55,14 +55,15 @@ void CDasherButtons::KeyDown(unsigned long iTime, Keys::VirtualKey Key, CDasherV
5555
}
5656

5757
void CDasherButtons::DirectKeyDown(unsigned long iTime, Keys::VirtualKey Key, CDasherView *pView, CDasherModel *pModel) {
58-
if(Key == Keys::Primary_Input) // Ignore mouse events
59-
return;
60-
if(Key == Keys::Button_1)
61-
iActiveBox = m_iNumBoxes - 1;
62-
else if(Key <= m_iNumBoxes)
63-
iActiveBox = Key-2;
64-
else
65-
iActiveBox = m_iNumBoxes-2;
58+
if(Key == Keys::Primary_Input) return; // Ignore mouse events
59+
60+
if(Key == Keys::Button_1) {
61+
iActiveBox = m_iNumBoxes - 1;
62+
} else if(Key <= m_iNumBoxes) {
63+
iActiveBox = Key-2;
64+
} else {
65+
iActiveBox = m_iNumBoxes-2;
66+
}
6667

6768
ScheduleZoom(pModel, m_pBoxes[iActiveBox].iTop,m_pBoxes[iActiveBox].iBottom);
6869
}

Src/DasherCore/DasherInterfaceBase.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#include "SmoothingFilter.h"
5656
#include "../DasherCore/FileLogger.h"
5757
#ifdef _DEBUG
58-
const eLogLevel g_iLogLevel = logDEBUG;
58+
const eLogLevel g_iLogLevel = eLogLevel::logDEBUG;
5959
const int g_iLogOptions = logTimeStamp | logDateStamp | logDeleteOldFile;
6060
#else
6161
const eLogLevel g_iLogLevel = logNORMAL;
@@ -775,20 +775,21 @@ void CDasherInterfaceBase::CreateModules() {
775775
void CDasherInterfaceBase::GetPermittedValues(Parameter parameter, std::vector<std::string> &vList) {
776776
// TODO: Deprecate direct calls to these functions
777777
switch (parameter) {
778-
case SP_ALPHABET_ID:
779-
DASHER_ASSERT(m_AlphIO != NULL);
780-
m_AlphIO->GetAlphabets(&vList);
781-
break;
782-
case SP_COLOUR_ID:
783-
DASHER_ASSERT(m_ColourIO != NULL);
784-
m_ColorIO->GetKnownPalettes(&vList);
785-
break;
786-
case SP_INPUT_FILTER:
787-
m_pModuleManager->ListInputMethodModules(vList);
788-
break;
789-
case SP_INPUT_DEVICE:
790-
m_pModuleManager->ListInputDeviceModules(vList);
791-
break;
778+
case SP_ALPHABET_ID:
779+
DASHER_ASSERT(m_AlphIO != NULL);
780+
m_AlphIO->GetAlphabets(&vList);
781+
break;
782+
case SP_COLOUR_ID:
783+
DASHER_ASSERT(m_ColourIO != NULL);
784+
m_ColorIO->GetKnownPalettes(&vList);
785+
break;
786+
case SP_INPUT_FILTER:
787+
m_pModuleManager->ListInputMethodModules(vList);
788+
break;
789+
case SP_INPUT_DEVICE:
790+
m_pModuleManager->ListInputDeviceModules(vList);
791+
break;
792+
default: break;
792793
}
793794
}
794795

Src/DasherCore/DemoFilter.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "DasherInterfaceBase.h"
66

7-
#include "CircleStartHandler.h"
87
#include "GameModule.h"
98

109
using namespace Dasher;
@@ -116,7 +115,7 @@ void CDemoFilter::HandleEvent(Parameter parameter) {
116115
case LP_DEMO_SPRING:
117116
case LP_DEMO_NOISE_MEM:
118117
case LP_MAX_BITRATE:
119-
case LP_FRAMERATE:
118+
case LP_FRAMERATE: {
120119
// Recalculates the parameters used in the demo following a change in framerate or speed.
121120
double spring = m_pSettingsStore->GetLongParameter(LP_DEMO_SPRING)/100.0;
122121
double noisemem = m_pSettingsStore->GetLongParameter(LP_DEMO_NOISE_MEM)/100.0;
@@ -125,5 +124,8 @@ void CDemoFilter::HandleEvent(Parameter parameter) {
125124
m_dSpring = (1-exp(-spring*lambda));
126125
m_dNoiseNew = noisemem*(1-exp(-lambda));
127126
m_dNoiseOld = sqrt(1.0-m_dNoiseNew*m_dNoiseNew);
127+
break;
128+
}
129+
default: break;
128130
}
129131
}

Src/DasherCore/ExpansionPolicy.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
*
88
*/
99

10-
#ifndef __ExpansionPolicy_h__
11-
#define __ExpansionPolicy_h__
10+
#pragma once
1211

1312
#include <vector>
1413
#include "DasherNode.h"
@@ -20,7 +19,8 @@ namespace Dasher {
2019
class CExpansionPolicy
2120
{
2221
public:
23-
virtual ~CExpansionPolicy() { };
22+
CExpansionPolicy() = default;
23+
virtual ~CExpansionPolicy() = default;
2424
///dMaxCost should be the value returned by pushNode from the call for the node most closely enclosing pNode (that was pushed!)
2525
///for the first (outermost) node, i.e. when no enclosing node has been passed, (+ive) INFINITY should be passed in.
2626
virtual double pushNode(CDasherNode *pNode, int iDasherMinY, int iDasherMaxY, bool bExpand, double dMaxCost)=0;
@@ -40,6 +40,7 @@ class NoExpansions : public CExpansionPolicy
4040
{
4141
public:
4242
NoExpansions() = default;
43+
virtual ~NoExpansions() = default;
4344
double pushNode(CDasherNode *pNode, int iMin, int iMax, bool bExpand, double dMaxCost) override {return dMaxCost;}
4445
bool apply() override {return false;}
4546
};
@@ -50,6 +51,7 @@ class BudgettingPolicy : public CExpansionPolicy
5051
{
5152
public:
5253
BudgettingPolicy(CDasherModel *pModel, unsigned int iNodeBudget);
54+
virtual ~BudgettingPolicy() = default;
5355
///sets cost according to getCost(pNode,iMin,iMax);
5456
///then assures node is cheaper (less important) than its parent;
5557
///then adds to relevant queue
@@ -68,14 +70,14 @@ class BudgettingPolicy : public CExpansionPolicy
6870
class AmortizedPolicy : public BudgettingPolicy
6971
{
7072
public:
73+
AmortizedPolicy() = delete;
7174
AmortizedPolicy(CDasherModel *pModel, unsigned int iNodeBudget);
7275
AmortizedPolicy(CDasherModel *pModel, unsigned int iNodeBudget, unsigned int iMaxExpands);
73-
~AmortizedPolicy() override = default;
76+
~AmortizedPolicy() = default;
7477
bool apply() override;
7578
double pushNode(CDasherNode *pNode, int iMin, int iMax, bool bExpand, double dParentCost) override;
7679
private:
7780
unsigned int m_iMaxExpands;
7881
void trim();
7982
};
8083
}
81-
#endif /*defined __ExpansionPolicy_h__*/

Src/DasherCore/FileLogger.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "FileUtils.h"
22

33
#include <string>
4-
#include <filesystem>
54
#include <chrono>
65
#include "FileLogger.h"
76

@@ -43,8 +42,8 @@ CFileLogger::~CFileLogger()
4342
if (!m_bFunctionTiming) return;
4443

4544
// Dump the results of our function timing logging
46-
Log("%-60s%20s%10s", logNORMAL, "Function","Ticks", "Percent");
47-
Log("%-60s%20s%10s", logNORMAL, "--------","-----", "-------");
45+
Log("%-60s%20s%10s", eLogLevel::logNORMAL, "Function","Ticks", "Percent");
46+
Log("%-60s%20s%10s", eLogLevel::logNORMAL, "--------","-----", "-------");
4847

4948
// First pass to count the max ticks
5049
// We assume that there was a function logger on the outer most (main) program.
@@ -58,7 +57,7 @@ CFileLogger::~CFileLogger()
5857

5958
for(const auto &[function_name, duration] : m_mapFunctionDuration)
6059
{
61-
Log("%-60s%20I64Ld%10.2f", logNORMAL, function_name.c_str(), duration, static_cast<double>(duration) / max_duration * 100.0);
60+
Log("%-60s%20I64Ld%10.2f", eLogLevel::logNORMAL, function_name.c_str(), duration, static_cast<double>(duration) / max_duration * 100.0);
6261
}
6362
}
6463

@@ -127,7 +126,7 @@ void CFileLogger::Log(const std::string strText, eLogLevel iLogLevel, ...)
127126
// Version that assume log level is logDEBUG
128127
void CFileLogger::LogDebug(const char* szText, ...)
129128
{
130-
if(m_iLogLevel > logDEBUG) return;
129+
if(m_iLogLevel > eLogLevel::logDEBUG) return;
131130

132131
va_list args;
133132

@@ -139,7 +138,7 @@ void CFileLogger::LogDebug(const char* szText, ...)
139138
// Version that assume log level is logNormal
140139
void CFileLogger::LogNormal(const char* szText, ...)
141140
{
142-
if(m_iLogLevel > logNORMAL) return;
141+
if(m_iLogLevel > eLogLevel::logNORMAL) return;
143142

144143
va_list args;
145144

0 commit comments

Comments
 (0)