-
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.
* wip: glob * interim towards glob * interim demo.cmd * glob * docopts: use existing args -> no copy * fix: make * fix: make
- Loading branch information
Showing
18 changed files
with
643 additions
and
86 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
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,58 @@ | ||
#pragma once | ||
#ifndef GLOB_H | ||
#define GLOB_H | ||
|
||
#include <SOM/BaseTypes.h> | ||
#include <SOM/coding.h> | ||
#include <SOM/fglob.h> | ||
|
||
#include <filesystem> | ||
#include <functional> | ||
#include <string> | ||
#include <vector> | ||
|
||
class I_GlobProcessor | ||
{ | ||
public: | ||
virtual void process(const std::string& fpath) = 0; | ||
virtual ~I_GlobProcessor() = default; | ||
}; | ||
|
||
|
||
class Glob | ||
{ | ||
public: | ||
Glob(I_GlobProcessor& proc, bool onlyFiles=false, bool onlyDirs=false); | ||
void glob(const std::string& fpath); | ||
|
||
private: | ||
using strVec = std::vector<std::string>; | ||
struct pathVec : strVec | ||
{ | ||
void add(const std::string& s); | ||
pathVec& operator << (const std::filesystem::directory_entry& e); | ||
}; | ||
|
||
using ffunc = std::function<bool(const std::string&)>; | ||
static const ffunc fd; | ||
static const ffunc ff; | ||
static const ffunc fx; | ||
static bool isGlob(const std::string& token); | ||
static void tokenize(strVec& tokens, const std::string& fpath); | ||
|
||
const bool onlyDirs; | ||
I_GlobProcessor& proc; | ||
const ffunc filter; | ||
pathVec buffs[2]; | ||
UINT8 pSrc = 0; | ||
UINT8 pTrg = 1; | ||
inline pathVec& getSrc() { return buffs[pSrc]; } | ||
inline pathVec& getTrg() { return buffs[pTrg]; } | ||
void getAll(); | ||
void getDirs(const pathVec& src, bool recursive=false); | ||
void getGlob(const std::string& token, bool dirs=false); | ||
void swap(); | ||
|
||
NOCOPY(Glob) | ||
}; | ||
#endif // _H |
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,37 @@ | ||
#pragma once | ||
#ifndef GLOBPROCESSORS_H | ||
#define GLOBPROCESSORS_H | ||
|
||
#include "Glob.h" | ||
#include <SOM/BaseTypes.h> | ||
#include <SOM/coding.h> | ||
|
||
#include <regex> | ||
|
||
class GlobTrace : public I_GlobProcessor | ||
{ | ||
public: | ||
void process(const std::string& fpath) override; | ||
}; | ||
|
||
class GlobXargs : public I_GlobProcessor | ||
{ | ||
public: | ||
GlobXargs(CONST_C_STRING cmd, CONST_C_STRING placeholder=nullptr); | ||
void process(const std::string& fpath) override; | ||
private: | ||
const std::string cmd; | ||
const std::regex re; | ||
NODEF(GlobXargs) | ||
NOCOPY(GlobXargs) | ||
}; | ||
|
||
class GlobArgs : public I_GlobProcessor | ||
{ | ||
public: | ||
GlobArgs(); | ||
~GlobArgs(); | ||
void process(const std::string& fpath) override; | ||
}; | ||
|
||
#endif // _H |
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
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.