Last active
December 15, 2015 03:19
-
-
Save timothy-shields/5193292 to your computer and use it in GitHub Desktop.
Example of creating an advanced query using linq-cpp
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
#include <linqcpp/linq/Enumerable.h> | |
#include <string> | |
#include <functional> | |
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
using namespace linq; | |
TEnumerable<string> FileLines(string path) | |
{ | |
return Enumerable::Factory<string>([=]() | |
{ | |
auto stream = make_shared<ifstream>(path); | |
return Enumerable::Generate([=]() | |
{ | |
string line; | |
std::getline(*stream, line); | |
return line; | |
}) | |
.TakeWhile([=](string line){ return !stream->eof(); }); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment