-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from optimisticninja/restructure
Restructure
- Loading branch information
Showing
11 changed files
with
195 additions
and
110 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
cmake_minimum_required(VERSION 2.6) | ||
project(iching) | ||
cmake_minimum_required(VERSION 3.1) | ||
project(iching VERSION 1.0.0 LANGUAGES CXX) | ||
add_subdirectory(src) | ||
#add_subdirectory(tests) | ||
|
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
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,23 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <sstream> | ||
#include <string> | ||
|
||
using std::vector; | ||
using std::string; | ||
|
||
namespace Lexer | ||
{ | ||
vector<string> strip_lines(const string& encoded_or_fname) | ||
{ | ||
vector<string> lines; | ||
std::stringstream ss(encoded_or_fname); | ||
string line = ""; | ||
|
||
while (std::getline(ss, line, '\n')) | ||
lines.push_back(line); | ||
|
||
return lines; | ||
} | ||
} |
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,34 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
|
||
#include "hexagram.h" | ||
|
||
using std::vector; | ||
|
||
namespace Parser | ||
{ | ||
static vector<string> lines_to_hexagrams(const vector<string>& lines) | ||
{ | ||
vector<string> continuous_hexagrams(NUM_HEXAGRAM_LINES); | ||
int i = 0; | ||
for (const string& line : lines) { | ||
i = i % NUM_HEXAGRAM_LINES == 0 ? 0 : i; | ||
continuous_hexagrams[i] += line; | ||
i += 1; | ||
} | ||
|
||
vector<string> hexagrams; | ||
for (size_t offset = 0; offset < continuous_hexagrams[0].length(); offset += HEXAGRAM_WIDTH) { | ||
string hexagram = ""; | ||
for (const string& line : continuous_hexagrams) { | ||
for (size_t j = offset; j < offset + HEXAGRAM_WIDTH; j++) | ||
hexagram += line[j]; | ||
hexagram += "\n"; | ||
} | ||
hexagrams.push_back(hexagram); | ||
} | ||
|
||
return hexagrams; | ||
} | ||
} |
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
Oops, something went wrong.