Skip to content

Instantly share code, notes, and snippets.

@timothy-shields
Last active December 15, 2015 03:19
Show Gist options
  • Save timothy-shields/5193292 to your computer and use it in GitHub Desktop.
Save timothy-shields/5193292 to your computer and use it in GitHub Desktop.
Example of creating an advanced query using linq-cpp
#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