Skip to content

Commit

Permalink
2.1.1 | Bug fixes | Element sturct uses less memory | Code Clean Up
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterMjir committed Dec 23, 2019
1 parent 3c23b20 commit 2f6da83
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 176 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ cmake_install.cmake
CMakeCache.txt
# Makefile
Makefile
# Clang Complete (Used for linting)
.clang_complete
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ A Periodic Table library

## Install
### Windows
1. Go to releases and install the .exe
1. Go to releases and install pTable_windows.zip

### Everyone else
1. Make sure you have CMake
2. Install the source (either download repo or go to releases and download source)
3. Unzip the zip and open a terminal in the directory with CMakeLists.txt
4. Run CMake
4. Run CMake (If you want to build on windows make sure you use ```cmake -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE```)

## Fine Print
- Currently doesn't have much functionality... (more features are planned!)
8 changes: 4 additions & 4 deletions lib/include/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

#include <string>

enum Property {NAME, SYMBOL, ATOMIC_NUMBER, PERIOD, GROUP, ELECTRONEGATIVITY, RADIUS};
enum ElementProperty {NAME, SYMBOL, ATOMIC_NUMBER, PERIOD, GROUP, ELECTRONEGATIVITY, RADIUS};

struct Element
{
std::string name;
std::string symbol;
unsigned short int atomicNumber;
short int period;
short int group;
uint8_t atomicNumber;
int8_t period;
int8_t group;
float electronegativity;
short int radius; // Calculated Radius
};
Expand Down
83 changes: 43 additions & 40 deletions lib/include/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,56 @@
#include <cctype>
#include <string>

/*
* void doNothing()
* ----------------
* Dummy function that does nothing
*/
void doNothing() {}
void doNothing(const std::vector<std::string> &) {}

/*
* bool checkstrnocase()
* ---------------------
* Checks string equality without case sensitivity
* Copied this over from https://thispointer.com/c-case-insensitive-string-comparison-using-stl-c11-boost-library/
*/
bool checkstrnocase(const std::string &str1, const std::string &str2)
namespace pTable
{
return ((str1.size() == str2.size()) &&
std::equal(str1.begin(), str1.end(), str2.begin(),
[](const char &c1, const char &c2) {return (c1 == c2 || std::toupper(c1) == std::toupper(c2));}
));
}
/*
* void doNothing()
* ----------------
* Dummy function that does nothing
*/
void doNothing() {}
void doNothing(const std::vector<std::string> &) {}

/*
* std::vector<std::string> seperateString()
* -----------------------------------------
* Separate a string into a vector of substrings separated by whatever character
*/
std::vector<std::string> seperateString(std::string str, std::string sepStr)
{
std::vector<std::string> list;
std::string word = "";
/*
* bool checkstrnocase()
* ---------------------
* Checks string equality without case sensitivity
* Copied this over from https://thispointer.com/c-case-insensitive-string-comparison-using-stl-c11-boost-library/
*/
bool checkstrnocase(const std::string &str1, const std::string &str2)
{
return ((str1.size() == str2.size()) &&
std::equal(str1.begin(), str1.end(), str2.begin(),
[](const char &c1, const char &c2) {return (c1 == c2 || std::toupper(c1) == std::toupper(c2));}
));
}

// Get the args
for (auto letter : str)
/*
* std::vector<std::string> seperateString()
* -----------------------------------------
* Separate a string into a vector of substrings separated by whatever character
*/
std::vector<std::string> seperateString(std::string str, std::string sepStr)
{
std::string strLetter(1, letter);
if (strLetter.compare(sepStr) == 0)
std::vector<std::string> list;
std::string word = "";

// Get the args
for (auto letter : str)
{
list.push_back(word);
word = "";
std::string strLetter(1, letter);
if (strLetter.compare(sepStr) == 0)
{
list.push_back(word);
word = "";
}
else
word += letter;
}
else
word += letter;
}
list.push_back(word);
list.push_back(word);

return list;
return list;
}
}

#endif
2 changes: 1 addition & 1 deletion lib/include/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define VERSION_MAJOR 2
#define VERSION_MINOR 1
#define VERSION_PATCH 0
#define VERSION_PATCH 1
Loading

0 comments on commit 2f6da83

Please sign in to comment.