Skip to content

Commit 9400397

Browse files
committed
Styleguide conformance
1 parent ee9616e commit 9400397

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+960
-965
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef _APPSTATE_H
22
#define _APPSTATE_H
33

4-
#include "SFMLEvent.h"
4+
#include "SFMLEvent.hpp"
55
#include <SFML/Graphics.hpp>
66

77
namespace chesspp
88
{
9-
//pure virtual abstract base class for game state management.
9+
//pure virtual abstract base class for game state management.
1010
class AppState : public SFMLEvent
1111
{
1212
public:
@@ -18,10 +18,10 @@ namespace chesspp
1818

1919
protected:
2020
sf::RenderWindow *display;
21-
};
21+
};
2222
}
2323

24-
#include "AppStateGame.h"
24+
#include "AppStateGame.hpp"
2525
/* Convenience header inclusion so we don't have to include each individual inheritor */
2626

27-
#endif
27+
#endif

src/AppStateGame.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "AppState.h"
1+
#include "AppState.hpp"
22

33
namespace chesspp
44
{
@@ -9,7 +9,7 @@ namespace chesspp
99
}
1010

1111
int AppStateGame::id() { return 1; }
12-
12+
1313
void AppStateGame::OnRender()
1414
{
1515
graphics.drawBoard(board);
@@ -18,7 +18,7 @@ namespace chesspp
1818
void AppStateGame::OnLButtonPressed(int x, int y)
1919
{
2020
board->setSelected(board->getCurrent()); // No matter if NULL
21-
}
21+
}
2222
void AppStateGame::OnMouseMoved(int x, int y)
2323
{
2424
board->setCurrent(x,y);
@@ -29,4 +29,4 @@ namespace chesspp
2929
board->move(board->getSelected(), x, y);
3030
board->setSelected(NULL);
3131
}
32-
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
#ifndef _APPSTATEGAME_H
2-
#define _APPSTATEGAME_H
2+
#define _APPSTATEGAME_H
33
#include "SFML.hpp"
4-
#include "TextureManager.h"
5-
#include "Graphics.h"
6-
#include "Configuration.h"
7-
#include "board/Board.h"
4+
#include "TextureManager.hpp"
5+
#include "Graphics.hpp"
6+
#include "Configuration.hpp"
7+
#include "board/Board.hpp"
88

99
#ifdef _DEBUG
10-
#include <iostream>
11-
using std::cout; using std::cin; using std::endl;
10+
#include <iostream>
11+
using std::cout; using std::cin; using std::endl;
1212
#endif
1313

1414
namespace chesspp
1515
{
1616
class Application;
1717
class AppStateGame : public AppState
1818
{
19-
Application* app;
19+
Application* app;
2020
Board* board;
2121

2222
graphics::GraphicsHandler graphics;
2323
configuration::BoardConfig boardConfig;
24-
24+
2525
public:
2626
AppStateGame(Application* _app, sf::RenderWindow *_display);
2727
virtual ~AppStateGame() {}
28-
28+
2929
virtual int id();
3030
virtual void OnRender();
3131

3232
virtual void OnLButtonPressed(int x, int y);
3333
virtual void OnLButtonReleased(int x, int y);
3434
virtual void OnMouseMoved(int x, int y);
35-
};
35+
};
3636
}
3737

38-
#endif
38+
#endif

src/Application.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#include "Application.h"
1+
#include "Application.hpp"
22
#include <iostream>
33

44
namespace chesspp
55
{
66
Application::Application()
7-
: display(sf::VideoMode(640, 640), "ChessPlusPlus", sf::Style::Close),
8-
running(true),
9-
state(new AppStateGame(this, &display))
7+
: display(sf::VideoMode(640, 640), "ChessPlusPlus", sf::Style::Close),
8+
running(true),
9+
state(new AppStateGame(this, &display))
1010
{
1111
display.setVerticalSyncEnabled(true);
1212
}
@@ -20,16 +20,16 @@ namespace chesspp
2020
OnEvent(&Event);
2121

2222
state->OnRender();
23-
display.display();
23+
display.display();
2424
}
25-
25+
2626
return 0;
2727
}
2828

2929
Application::~Application()
3030
{
31-
delete state; //Even if it's null, no matter.
32-
}
31+
delete state; //Even if it's null, no matter.
32+
}
3333

3434
void Application::OnEvent(sf::Event *Event)
3535
{
@@ -175,4 +175,4 @@ namespace chesspp
175175
}
176176
}
177177

178-
}
178+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _APPLICATION_H
2-
#define _APPLICATION_H
2+
#define _APPLICATION_H
33

4-
#include "AppState.h"
4+
#include "AppState.hpp"
55

66
namespace chesspp
77
{
@@ -10,9 +10,9 @@ namespace chesspp
1010
sf::RenderWindow display;
1111
bool running;
1212
AppState* state;
13-
void OnEvent(sf::Event *Event);
13+
void OnEvent(sf::Event *Event);
1414

15-
public:
15+
public:
1616
Application();
1717
~Application();
1818

@@ -22,7 +22,7 @@ namespace chesspp
2222
state = new NewState;
2323
}
2424
int Exec();
25-
};
25+
};
2626
}
2727

28-
#endif
28+
#endif

src/Configuration.h renamed to src/Configuration.hpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef _CONFIGURATION_H
22
#define _CONFIGURATION_H
33

4-
#include <string.h>
5-
#include <stdint.h>
4+
#include <cstring>
5+
#include <cstdint>
66
#include <boost/algorithm/string/replace.hpp>
77

88
#if defined(__linux__)
@@ -14,9 +14,9 @@
1414
#endif
1515

1616

17-
#include "Exception.h"
18-
#include "XMLReader.h"
19-
#include "board/logger.h"
17+
#include "Exception.hpp"
18+
#include "XMLReader.hpp"
19+
#include "board/logger.hpp"
2020

2121
namespace chesspp
2222
{
@@ -26,7 +26,7 @@ namespace chesspp
2626
{
2727
protected:
2828
std::string res_path;
29-
29+
3030
//Linux and Windows, resource path is defined as the absolute path the folder where the application executable is stored.
3131
// <exe_location>/res/img/... should be where resources are stored.
3232
//OS x, resource path is defined as the absolute path to the Resources folder of the .app structure.
@@ -49,7 +49,7 @@ namespace chesspp
4949
ret = buf;
5050
boost::replace_all(ret, "\\", "/");
5151
ret = ret.substr(0, ret.find_last_of('/')+1);
52-
52+
5353
#elif defined(__APPLE__)
5454
if (_NSGetExecutablePath(buf, &size) != 0)
5555
throw chesspp::exception("Unable to determine executable path on OS x. (Buffer size too small?)");
@@ -60,7 +60,7 @@ namespace chesspp
6060

6161
#else
6262
throw chesspp::exception("Unknown OS. Unable to determine executable path.");
63-
#endif
63+
#endif
6464

6565
return ret;
6666
}
@@ -69,7 +69,7 @@ namespace chesspp
6969
public:
7070
configuration(const std::string &configFile) : res_path(getResourcePath()), reader(getResourcePath() + configFile) {}
7171
virtual ~configuration() {}
72-
72+
7373
};
7474

7575
class BoardConfig : public configuration
@@ -79,15 +79,15 @@ namespace chesspp
7979
uint16_t cell_width, cell_height;
8080

8181
public:
82-
BoardConfig() : configuration("config.xml")
82+
BoardConfig() : configuration("config.xml")
8383
{
8484
initial_layout = res_path + reader.getProperty<std::string>("chesspp.data.board.initial_layout");
8585
board_width = reader.getProperty<uint8_t>("chesspp.data.board.width");
8686
board_height = reader.getProperty<uint8_t>("chesspp.data.board.height");
8787
cell_width = reader.getProperty<uint16_t>("chesspp.data.board.cell_width");
8888
cell_height = reader.getProperty<uint16_t>("chesspp.data.board.cell_height");
8989
}
90-
90+
9191
std::string getInitialLayout() { return initial_layout; }
9292
uint8_t getBoardWidth() { return board_width; }
9393
uint8_t getBoardHeight() { return board_height; }
@@ -111,7 +111,7 @@ namespace chesspp
111111
std::string getSpritePath_pieces() { return path_pieces; }
112112
std::string getSpritePath_validMove() { return path_validMove; }
113113
};
114-
}
114+
}
115115
}
116116

117-
#endif
117+
#endif

src/Exception.h renamed to src/Exception.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ namespace chesspp
1616

1717
exception(const std::string &_e) throw() : e(_e) {}
1818
virtual const char *what() { return e.c_str(); }
19-
19+
2020
private:
2121
std::string e;
2222
};
2323
}
2424

25-
#endif
25+
#endif

src/Graphics.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "Graphics.h"
1+
#include "Graphics.hpp"
22

33
namespace chesspp
44
{
@@ -85,4 +85,4 @@ namespace chesspp
8585
drawPieceAt(b->getSelected(), sf::Mouse::getPosition(*display));
8686
}
8787
}
88-
}
88+
}

src/Graphics.h renamed to src/Graphics.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
#define _GRAPHICS_H
33

44
#include "SFML.hpp"
5-
#include "TextureManager.h"
6-
#include "Configuration.h"
7-
#include "board/Piece.h"
8-
#include "board/logger.h"
5+
#include "TextureManager.hpp"
6+
#include "Configuration.hpp"
7+
#include "board/Piece.hpp"
8+
#include "board/logger.hpp"
99

1010
#ifdef _DEBUG
1111
#include <iostream>
@@ -21,7 +21,7 @@ namespace chesspp
2121
sf::Sprite board, pieces, validMove;
2222
uint16_t cell_size;
2323
sf::RenderWindow *display;
24-
24+
2525
public:
2626
GraphicsHandler(sf::RenderWindow *_display);
2727

@@ -46,4 +46,4 @@ namespace chesspp
4646
}
4747
}
4848

49-
#endif
49+
#endif

src/Main.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include "Application.h"
1+
#include "Application.hpp"
22

33
int main()
44
{
5-
chesspp::Application app;
6-
return app.Exec();
7-
}
5+
chesspp::Application app;
6+
return app.Exec();
7+
}

src/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ Style Guide & Coding Conventions
44
- All files are to have a single blank line at their end, if possible.
55
- Prefer C++11 features to C++03 features when possible, and avoid deprecated language features.
66
- When using C++11 features, try to use those which are supported by at least both clang++ and gcc
7+
- Prefer to use `<c____>` rather than `<____.h>` for C standard library headers
78
- Prefer use of `class` to `struct` for declaring classes (this means you need to explicitly specify public inheritance).
89
- Prefer to use file extensions .cpp and .hpp (using .h may cause the file to be detected as C or Objective-C rather than C++)
910
- Prefer `lowercase` namespace, parameter, and local variable names.
1011
- Prefer `UpperCamelCase` for class names
1112
- Prefer `lowerCamelCase` for member function names
1213
- Prefer `lower_case_underscore` private member names
14+
- Braces should be on their own lines, even for empty definitions
15+
- Namespaces cause indentation to occur, inclusion guards do not
1316
- Avoid using raw pointers when possible
1417
- Prefer creating `using` declarations to using raw primitive types
1518
- Avoid use of exceptions when possible

0 commit comments

Comments
 (0)