Skip to content

Commit

Permalink
V1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sherlock committed Aug 17, 2018
1 parent 8fdade4 commit 2e4f8c8
Show file tree
Hide file tree
Showing 17 changed files with 612 additions and 617 deletions.
370 changes: 158 additions & 212 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CodeTests/ComplexDataStructureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../File.h"

using namespace std;
using namespace FilesApi;

int mainComplexDataStructureTest() {
File f("../Test/test_file.bin");
Expand Down
1 change: 1 addition & 0 deletions CodeTests/ExceptionsTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "../File.h"

using namespace std;
using namespace FilesApi;

int mainExceptionsTest() {
File f("../Test/not_exist_file.bin", true);
Expand Down
1 change: 1 addition & 0 deletions CodeTests/FileTestNotVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../File.h"

using namespace std;
using namespace FilesApi;

int mainFileTestNotVector() {
File f("../Test/test_file.bin");
Expand Down
1 change: 1 addition & 0 deletions CodeTests/FileTestOpertorsNotVectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../File.h"

using namespace std;
using namespace FilesApi;

int mainFileTestOpertorsNotVectors() {
File f("../Test/test_file.bin");
Expand Down
1 change: 1 addition & 0 deletions CodeTests/FileTestOpertorsVectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../File.h"

using namespace std;
using namespace FilesApi;

int mainFileTestOpertorsVectors() {
File f("../Test/test_file.bin");
Expand Down
1 change: 1 addition & 0 deletions CodeTests/FileTestVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../File.h"

using namespace std;
using namespace FilesApi;

int mainFileTestVector() {
File f("../Test/test_file.bin");
Expand Down
2 changes: 1 addition & 1 deletion CodeTests/FilesManagerOperatorsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "../FilesManager.h"

using namespace std;

using namespace FilesApi;

int mainFilesManagerOperatorsTest() {
FilesManager fm(false, 0, "../Test/");
Expand Down
2 changes: 1 addition & 1 deletion CodeTests/FilesManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "../FilesManager.h"

using namespace std;

using namespace FilesApi;

int mainFilesManagerTest() {
FilesManager fm;
Expand Down
72 changes: 36 additions & 36 deletions DesignText.cpp
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
#include "DesignText.h"
namespace FilesApi {
namespace DesignText {
inline std::string BoolToString(bool b) {
return b ? "1" : "0";
}

namespace DesignText {
inline std::string BoolToString(bool b)
{
return b ? "1" : "0";
}

std::string make_colored(const std::string &text, Color color, bool bold) {
std::string new_text;
new_text = "\033[";
switch (color) {
case Color::BLACK:
new_text += BoolToString(bold) + ";30m" + text;
break;
case Color::RED:
new_text += BoolToString(bold) + ";31m" + text;
break;
case Color::GREEN:
new_text += BoolToString(bold) + ";32m" + text;
break;
case Color::YELLOW:
new_text += BoolToString(bold) + ";33m" + text;
break;
case Color::BLUE:
new_text += BoolToString(bold) + ";34m" + text;
break;
case Color::MAGENTA:
new_text += BoolToString(bold) + ";35m" + text;
break;
case Color::CYAN:
new_text += BoolToString(bold) + ";36m" + text;
break;
case Color::WHITE:
new_text += BoolToString(bold) + ";37m" + text;
break;
std::string make_colored(const std::string &text, Color color, bool bold) {
std::string new_text;
new_text = "\033[";
switch (color) {
case Color::BLACK:
new_text += BoolToString(bold) + ";30m" + text;
break;
case Color::RED:
new_text += BoolToString(bold) + ";31m" + text;
break;
case Color::GREEN:
new_text += BoolToString(bold) + ";32m" + text;
break;
case Color::YELLOW:
new_text += BoolToString(bold) + ";33m" + text;
break;
case Color::BLUE:
new_text += BoolToString(bold) + ";34m" + text;
break;
case Color::MAGENTA:
new_text += BoolToString(bold) + ";35m" + text;
break;
case Color::CYAN:
new_text += BoolToString(bold) + ";36m" + text;
break;
case Color::WHITE:
new_text += BoolToString(bold) + ";37m" + text;
break;
}
new_text += "\033[0m";
return new_text;
}
new_text += "\033[0m";
return new_text;
}
}
28 changes: 14 additions & 14 deletions DesignText.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
#define FILESAPI_DESIGNTEXT_H

#include <iostream>
namespace FilesApi {
namespace DesignText {
enum class Color {
BLACK,
RED,
GREEN,
YELLOW,
BLUE,
MAGENTA,
CYAN,
WHITE
};

namespace DesignText {
enum class Color {
BLACK,
RED,
GREEN,
YELLOW,
BLUE,
MAGENTA,
CYAN,
WHITE
};

std::string make_colored(const std::string &text, Color color, bool bold);
std::string make_colored(const std::string &text, Color color, bool bold);
}
}

#endif //FILESAPI_DESIGNTEXT_H
29 changes: 14 additions & 15 deletions Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
#include <iostream>
#include <exception>

namespace FilesApi {
class FileOpenException : public std::runtime_error {
std::string _file_name;
std::string what_message;

class FileOpenException: public std::runtime_error
{
std::string _file_name;
std::string what_message;
public:
explicit FileOpenException(const std::string &file_name) : runtime_error("") {
_file_name = file_name;
what_message = "Can't open file '" + _file_name + "' exception.";
}

public:
explicit FileOpenException(const std::string &file_name) : runtime_error("") {
_file_name = file_name;
what_message = "Can't open file '" + _file_name + "' exception.";
}

virtual const char* what() const throw()
{
return what_message.c_str();
}
};
virtual const char *what() const throw() {
return what_message.c_str();
}
};
}

#endif //FILESAPI_EXCEPTIONS_H
Loading

0 comments on commit 2e4f8c8

Please sign in to comment.