-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lee
committed
Jun 11, 2018
1 parent
0e42ee5
commit 714e431
Showing
10 changed files
with
523 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Mac", | ||
"includePath": [ | ||
"/usr/include", | ||
"/usr/local/include", | ||
"${workspaceRoot}" | ||
], | ||
"defines": [], | ||
"intelliSenseMode": "clang-x64", | ||
"browse": { | ||
"path": [ | ||
"/usr/include", | ||
"/usr/local/include", | ||
"${workspaceRoot}" | ||
], | ||
"limitSymbolsToIncludedHeaders": true, | ||
"databaseFilename": "" | ||
}, | ||
"macFrameworkPath": [ | ||
"/System/Library/Frameworks", | ||
"/Library/Frameworks" | ||
] | ||
}, | ||
{ | ||
"name": "Linux", | ||
"includePath": [ | ||
"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5", | ||
"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux", | ||
"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward", | ||
"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include", | ||
"/usr/local/include", | ||
"/usr/include", | ||
"${workspaceRoot}", | ||
"${workspaceRoot}/header" | ||
], | ||
"defines": [], | ||
"intelliSenseMode": "clang-x64", | ||
"browse": { | ||
"path": [ | ||
"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5", | ||
"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux", | ||
"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward", | ||
"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include", | ||
"/usr/local/include", | ||
"/usr/include", | ||
"${workspaceRoot}", | ||
"${workspaceRoot}/header" | ||
], | ||
"limitSymbolsToIncludedHeaders": true, | ||
"databaseFilename": "" | ||
}, | ||
"compilerPath": "/usr/bin/gcc", | ||
"cStandard": "c11", | ||
"cppStandard": "c++14" | ||
}, | ||
{ | ||
"name": "Win32", | ||
"includePath": [ | ||
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include", | ||
"${workspaceRoot}" | ||
], | ||
"defines": [ | ||
"_DEBUG", | ||
"UNICODE", | ||
"_UNICODE" | ||
], | ||
"intelliSenseMode": "msvc-x64", | ||
"browse": { | ||
"path": [ | ||
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*", | ||
"${workspaceRoot}" | ||
], | ||
"limitSymbolsToIncludedHeaders": true, | ||
"databaseFilename": "" | ||
} | ||
} | ||
], | ||
"version": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
// https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "(gdb) Launch", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/a.out", | ||
"args": [], | ||
"stopAtEntry": false, | ||
"cwd": "${workspaceFolder}", | ||
"environment": [], | ||
"externalConsole": true, | ||
"MIMode": "gdb", | ||
"setupCommands": [ | ||
{ | ||
"description": "Enable pretty-printing for gdb", | ||
"text": "-enable-pretty-printing", | ||
"ignoreFailures": true | ||
} | ||
], | ||
//"internalConsoleOptions": "neverOpen", | ||
"preLaunchTask": "main", | ||
"additionalSOLibSearchPath": "" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"files.associations": { | ||
"iostream": "cpp", | ||
"ostream": "cpp", | ||
"cmath": "cpp", | ||
"climits": "cpp", | ||
"cfloat": "cpp", | ||
"array": "cpp", | ||
"istream": "cpp", | ||
"typeinfo": "cpp", | ||
"string": "cpp", | ||
"*.tcc": "cpp", | ||
"cctype": "cpp", | ||
"clocale": "cpp", | ||
"cstdint": "cpp", | ||
"cstdio": "cpp", | ||
"cstdlib": "cpp", | ||
"cstring": "cpp", | ||
"cwchar": "cpp", | ||
"cwctype": "cpp", | ||
"exception": "cpp", | ||
"fstream": "cpp", | ||
"initializer_list": "cpp", | ||
"iosfwd": "cpp", | ||
"limits": "cpp", | ||
"new": "cpp", | ||
"stdexcept": "cpp", | ||
"streambuf": "cpp", | ||
"type_traits": "cpp", | ||
"unordered_map": "cpp", | ||
"vector": "cpp", | ||
"functional": "cpp", | ||
"sstream": "cpp", | ||
"tuple": "cpp", | ||
"utility": "cpp" | ||
}, | ||
"C_Cpp.errorSquiggles": "Disabled" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "main", | ||
"type": "shell", | ||
"command": "g++", | ||
"args": [ | ||
"-g", | ||
"-std=c++11", | ||
"-Wall", | ||
"main.cpp", | ||
"file.cpp", | ||
"debug.cpp" | ||
], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include <stdio.h> | ||
#include <sys/time.h> | ||
#include <time.h> | ||
#include <stdarg.h> | ||
#include "header/debug.h" | ||
|
||
#define ANSI_COLOR_RED "\x1b[1;31m" | ||
#define ANSI_COLOR_GREEN "\x1b[1;32m" | ||
#define ANSI_COLOR_YELLOW "\x1b[1;33m" | ||
#define ANSI_COLOR_PURPLE "\x1b[1;35m" | ||
#define ANSI_COLOR_CYAN "\x1b[29m" | ||
#define ANSI_COLOR_CYAN_LESS "\x1b[29m" | ||
#define ANSI_COLOR_RESET "\x1b[0m" | ||
|
||
#define PRINT_DEBUG "DEBUG" | ||
#define PRINT_INFO "INFO" | ||
#define PRINT_WARN "WARN" | ||
#define PRINT_ERROR "ERROR" | ||
|
||
#define PRINT_LEN 10240 | ||
|
||
static void _common_printf(FILE * fp, const char * time_cl, const char * type_cl, | ||
const char * func_cl, const char * content_cl, | ||
const char * level, const char * file, | ||
const int line, const char * func, const char * fmt) | ||
{ | ||
struct timeval tv; | ||
gettimeofday(&tv, NULL); | ||
char datestr[20]; | ||
struct tm tm; | ||
time_t timesec = tv.tv_sec; | ||
localtime_r(×ec, &tm); | ||
strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm); | ||
/* fprintf(fp, "%s" "%s.%06ld " ANSI_COLOR_RESET | ||
"%s" "[%-05s]" ANSI_COLOR_RESET | ||
"%s" "[%s, %4d][%-10s] " ANSI_COLOR_RESET | ||
"%s" "%s" ANSI_COLOR_RESET, | ||
time_cl, datestr, tv.tv_usec, type_cl, | ||
level, func_cl, file, line, func, content_cl, fmt); */ | ||
fprintf(fp, "%s" "[%-05s]" ANSI_COLOR_RESET | ||
"%s" "[%s,%d] " ANSI_COLOR_RESET | ||
"%s" "%s" ANSI_COLOR_RESET, | ||
type_cl,level, func_cl, file, line, content_cl, fmt); | ||
fflush(fp); | ||
} | ||
|
||
int common_printf(FILE * fp, const int level, const char * file, | ||
const int line, const char * func, const char * fmt, ...) | ||
{ | ||
int i; | ||
char buf[PRINT_LEN]; | ||
|
||
va_list args; | ||
va_start(args, fmt); | ||
i = vsnprintf(buf, PRINT_LEN, fmt, args); | ||
va_end(args); | ||
|
||
switch (level) { | ||
case LEVEL_DEBUG: | ||
_common_printf(fp, ANSI_COLOR_CYAN_LESS, ANSI_COLOR_GREEN, | ||
ANSI_COLOR_CYAN, ANSI_COLOR_GREEN, | ||
PRINT_DEBUG, file, line, func, buf); | ||
break; | ||
|
||
case LEVEL_INFO: | ||
_common_printf(fp, ANSI_COLOR_CYAN_LESS, ANSI_COLOR_YELLOW, | ||
ANSI_COLOR_CYAN, ANSI_COLOR_YELLOW, | ||
PRINT_INFO, file, line, func, buf); | ||
break; | ||
|
||
case LEVEL_WARN: | ||
_common_printf(fp, ANSI_COLOR_CYAN_LESS, ANSI_COLOR_PURPLE, | ||
ANSI_COLOR_CYAN, ANSI_COLOR_PURPLE, | ||
PRINT_WARN, file, line, func, buf); | ||
break; | ||
case LEVEL_ERROR: | ||
_common_printf(fp, ANSI_COLOR_CYAN_LESS, ANSI_COLOR_RED, | ||
ANSI_COLOR_CYAN, ANSI_COLOR_RED, | ||
PRINT_ERROR, file, line, func, buf); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
return i; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#include <iostream> | ||
#include <cstring> | ||
#include "header/file.h" | ||
|
||
using namespace std; | ||
|
||
|
||
int StringMe::num_strings = 0; | ||
|
||
StringMe::StringMe(const char *s) : myyear(0),values(0) | ||
{ | ||
show("StringMe::StringMe(const char *s)\n"); | ||
len = std::strlen(s); | ||
str = new char[len + 1]; | ||
std::strcpy(str, s); | ||
num_strings ++; | ||
} | ||
|
||
StringMe::StringMe(const StringMe & st):values(0) | ||
{ | ||
show("StringMe::StringMe(const StringMe &)\n"); | ||
num_strings++; | ||
len = st.len; | ||
str = new char[len + 1]; | ||
std::strcpy(str, st.str); | ||
} | ||
|
||
StringMe::StringMe():values(0) | ||
{ | ||
show("StringMe::StringMe()\n"); | ||
len = 5; | ||
str = new char[len + 1]; | ||
std::strcpy(str, "empty"); | ||
num_strings++; | ||
} | ||
|
||
StringMe::~StringMe() | ||
{ | ||
show("~StringMe::StringMe()\n"); | ||
print(); | ||
delete [] str; | ||
num_strings--; | ||
} | ||
|
||
std::ostream & operator<<(std::ostream & os, | ||
const StringMe & st) | ||
{ | ||
os << st.str; | ||
return os; | ||
} | ||
|
||
void StringMe::print(void) | ||
{ | ||
cout << "str: " << str << endl; | ||
cout << "num_strings: " << num_strings << endl; | ||
} | ||
|
||
StringMe & StringMe::operator=(const StringMe & st) | ||
{ | ||
show("StringMe & StringMe::operator=(const StringMe & st)\n"); | ||
|
||
if (this == &st) { | ||
return *this; | ||
} | ||
|
||
delete [] str; | ||
len = st.len; | ||
str = new char [len + 1]; | ||
std::strcpy(str, st.str); | ||
|
||
return *this; | ||
} | ||
|
||
StringMe & StringMe::operator=(const char * s) | ||
{ | ||
show("StringMe & StringMe::operator=(const char * s)\n"); | ||
delete [] str; | ||
len = std::strlen(s); | ||
str = new char[len+1]; | ||
std::strcpy(str, s); | ||
return *this; | ||
} | ||
|
||
char & StringMe::operator[](int i) | ||
{ | ||
show("char & StringMe::operator[](int i)\n"); | ||
return str[i]; | ||
} | ||
|
||
const char & StringMe::operator[](int i) const | ||
{ | ||
show("const char & StringMe::operator[](int i) const\n"); | ||
return str[i]; | ||
} | ||
|
||
reStringMe::reStringMe (const char * str, int r) : StringMe(str) | ||
{ | ||
show("reStringMe::reStringMe (int r, const char * str) : StringMe(str)\n"); | ||
rating = r; | ||
} | ||
|
||
reStringMe::reStringMe (int r, const StringMe & s) : rating(r), StringMe(s) | ||
{ | ||
show("reStringMe::reStringMe (int r, const StringMe & s) : rating(r), StringMe(s)\n"); | ||
} | ||
|
||
reStringMe::~reStringMe() | ||
{ | ||
show("reStringMe::~reStringMe()\n"); | ||
} |
Oops, something went wrong.