-
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.
Merge pull request #2 from VitusVeit/dev
Examples push
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <iostream> | ||
#include "../tsvParser.hpp" | ||
|
||
int main() | ||
{ | ||
tsv::File myFile; | ||
|
||
// You can create a row by a vector of strings. | ||
myFile[0] = {"Name", "Age", "Job", "NA"}; | ||
|
||
myFile += tsv::Row({"Frank Freeman", "45", "Nuclear Scientist"}); | ||
|
||
// Or add them manually. | ||
tsv::Row r1; | ||
|
||
r1 += "Mario Rossi"; | ||
r1 += "25"; | ||
|
||
myFile += r1; | ||
|
||
myFile[2] += "Bean Counter"; | ||
|
||
// You can also access individual columns given their rows. | ||
myFile[2][1] = "32"; | ||
|
||
// You can remove a specific value from a row. | ||
myFile[0] -= "NA"; | ||
|
||
// Use 'ToString' to convert the TSV class to a text format. | ||
std::cout << myFile.ToString() << '\n'; | ||
} |
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,16 @@ | ||
#include <iostream> | ||
#include "../tsvParser.hpp" | ||
|
||
int main() | ||
{ | ||
tsv::File antherFileOfMine; | ||
|
||
// You can open other files or read from strings with 'OpenFile' and 'OpenString'. | ||
antherFileOfMine.OpenFile("test.tsv"); | ||
|
||
// Modify it a bit... | ||
antherFileOfMine[3][0] = "Chocolate Bar"; | ||
|
||
// ...and also export it to a file or turn it into a string with 'ToFile' and 'ToString'! | ||
antherFileOfMine.ToFile("shoppingList.tsv"); | ||
} |
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,28 @@ | ||
#include <iostream> | ||
#include "../tsvParser.hpp" | ||
|
||
int main() | ||
{ | ||
tsv::File myFile; | ||
|
||
myFile[0] = {"Integer", "Decimal", "Exponential"}; | ||
|
||
// Create a row. | ||
tsv::Row r1; | ||
|
||
// You can add integer and double numbers directly. | ||
r1 += 4; | ||
r1 += 2.2; | ||
|
||
// Or add a string that follows the Google Sheets format or other spreadsheet editors. | ||
r1[1] += "2,24"; | ||
|
||
// You add exponential numbers too, both directly and by string! | ||
r1 += 2.3e+2; | ||
r1[2] = "2.3e+2"; | ||
|
||
// Add the row to the file. | ||
myFile += r1; | ||
|
||
std::cout << myFile.ToString() << '\n'; | ||
} |
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,4 @@ | ||
Product Quantity Price | ||
Apple 4 2,5 | ||
Bread 1 5 | ||
NameNotGiven 5 1,2 |