moved regular expression classes into a separate namespace

This commit is contained in:
mr-alice 2016-09-13 12:05:22 +02:00
parent e9418bb5c6
commit a2e34f9cc6
25 changed files with 439 additions and 426 deletions

View File

@ -173,8 +173,8 @@ void FileSearchHandler::handleCreateSearch(Request &req, Response &resp)
return;
}
NameExpression exprs(ContainsAllStrings,words,true) ;
LinearizedExpression lin_exp ;
RsRegularExpression::NameExpression exprs(RsRegularExpression::ContainsAllStrings,words,true) ;
RsRegularExpression::LinearizedExpression lin_exp ;
exprs.linearize(lin_exp) ;
uint32_t search_id = RSRandom::random_u32();

View File

@ -595,7 +595,7 @@ bool InternalFileHierarchyStorage::searchHash(const RsFileHash& hash,std::list<D
return false;
}
int InternalFileHierarchyStorage::searchBoolExp(Expression * exp, std::list<DirectoryStorage::EntryIndex> &results) const
int InternalFileHierarchyStorage::searchBoolExp(RsRegularExpression::Expression * exp, std::list<DirectoryStorage::EntryIndex> &results) const
{
#ifdef TODO
for(std::map<RsFileHash,DirectoryStorage::EntryIndex>::const_iterator it(mFileHashes.begin());it!=mFileHashes.end();++it)

View File

@ -140,7 +140,7 @@ public:
// search. SearchHash is logarithmic. The other two are linear.
bool searchHash(const RsFileHash& hash,std::list<DirectoryStorage::EntryIndex>& results);
int searchBoolExp(Expression * exp, std::list<DirectoryStorage::EntryIndex> &results) const ;
int searchBoolExp(RsRegularExpression::Expression * exp, std::list<DirectoryStorage::EntryIndex> &results) const ;
int searchTerms(const std::list<std::string>& terms, std::list<DirectoryStorage::EntryIndex> &results) const ;
bool check(std::string& error_string) const ;// checks consistency of storage.

View File

@ -203,7 +203,7 @@ int DirectoryStorage::searchTerms(const std::list<std::string>& terms, std::list
RS_STACK_MUTEX(mDirStorageMtx) ;
return mFileHierarchy->searchTerms(terms,results);
}
int DirectoryStorage::searchBoolExp(Expression * exp, std::list<EntryIndex> &results) const
int DirectoryStorage::searchBoolExp(RsRegularExpression::Expression * exp, std::list<EntryIndex> &results) const
{
RS_STACK_MUTEX(mDirStorageMtx) ;
return mFileHierarchy->searchBoolExp(exp,results);

View File

@ -50,7 +50,7 @@ class DirectoryStorage
void save() const ;
virtual int searchTerms(const std::list<std::string>& terms, std::list<EntryIndex> &results) const ;
virtual int searchBoolExp(Expression * exp, std::list<EntryIndex> &results) const ;
virtual int searchBoolExp(RsRegularExpression::Expression * exp, std::list<EntryIndex> &results) const ;
virtual int searchHash(const RsFileHash& hash, std::list<EntryIndex> &results) const ;
bool getDirUpdateTS(EntryIndex index,time_t& recurs_max_modf_TS,time_t& local_update_TS) ;

View File

@ -814,7 +814,7 @@ int p3FileDatabase::SearchKeywords(const std::list<std::string>& keywords, std::
return filterResults(firesults,results,flags,client_peer_id) ;
}
int p3FileDatabase::SearchBoolExp(Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& client_peer_id) const
int p3FileDatabase::SearchBoolExp(RsRegularExpression::Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& client_peer_id) const
{
RS_STACK_MUTEX(mFLSMtx) ;

View File

@ -103,7 +103,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
virtual bool findLocalFile(const RsFileHash& hash,FileSearchFlags flags,const RsPeerId& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const;
virtual int SearchKeywords(const std::list<std::string>& keywords, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) ;
virtual int SearchBoolExp(Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
virtual int SearchBoolExp(RsRegularExpression::Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
// ftSearch
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;

View File

@ -26,6 +26,7 @@
#include "dbase/findex.h"
#include "retroshare/rsexpr.h"
#include "retroshare/rstypes.h"
#include <algorithm>
#include <functional>
@ -34,6 +35,8 @@ eval functions of relational expressions.
******************************************************************************************/
namespace RsRegularExpression
{
template<>
void RelExpression<int>::linearize(LinearizedExpression& e) const
{
@ -43,24 +46,24 @@ void RelExpression<int>::linearize(LinearizedExpression& e) const
}
bool DateExpression::eval(FileEntry *file)
bool DateExpression::eval(const ExpFileEntry& file)
{
return evalRel(file->modtime);
return evalRel(file.file_modtime());
}
bool SizeExpressionMB::eval(FileEntry *file)
bool SizeExpressionMB::eval(const ExpFileEntry& file)
{
return evalRel((int)(file->size/(uint64_t)(1024*1024)));
return evalRel((int)(file.file_size()/(uint64_t)(1024*1024)));
}
bool SizeExpression::eval(FileEntry *file)
bool SizeExpression::eval(const ExpFileEntry& file)
{
return evalRel(file->size);
return evalRel(file.file_size());
}
bool PopExpression::eval(FileEntry *file)
bool PopExpression::eval(const ExpFileEntry& file)
{
return evalRel(file->pop);
return evalRel(file.file_popularity());
}
/******************************************************************************************
@ -68,28 +71,23 @@ Code for evaluating string expressions
******************************************************************************************/
bool NameExpression::eval(FileEntry *file)
bool NameExpression::eval(const ExpFileEntry& file)
{
return evalStr(file->name);
return evalStr(file.file_name());
}
bool PathExpression::eval(FileEntry *file){
std::string path;
/*Construct the path of this file*/
DirEntry * curr = file->parent;
while ( curr != NULL ){
path = curr->name+"/"+ path;
curr = curr->parent;
}
return evalStr(path);
bool PathExpression::eval(const ExpFileEntry& file)
{
return evalStr(file.file_parent_path());
}
bool ExtExpression::eval(FileEntry *file){
bool ExtExpression::eval(const ExpFileEntry& file)
{
std::string ext;
/*Get the part of the string after the last instance of . in the filename */
size_t index = file->name.find_last_of('.');
size_t index = file.file_name().find_last_of('.');
if (index != std::string::npos) {
ext = file->name.substr(index+1);
ext = file.file_name().substr(index+1);
if (ext != "" ){
return evalStr(ext);
}
@ -97,8 +95,8 @@ bool ExtExpression::eval(FileEntry *file){
return false;
}
bool HashExpression::eval(FileEntry *file){
return evalStr(file->hash.toStdString());
bool HashExpression::eval(const ExpFileEntry& file){
return evalStr(file.file_hash().toStdString());
}
/*Check whether two strings are 'equal' to each other*/
@ -287,3 +285,4 @@ Expression *LinearizedExpression::toExpr(const LinearizedExpression& e,int& n_to
}
}

View File

@ -569,11 +569,11 @@ int ftServer::SearchKeywords(std::list<std::string> keywords, std::list<DirDetai
return mFileDatabase->SearchKeywords(keywords, results,flags,peer_id);
}
int ftServer::SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags)
int ftServer::SearchBoolExp(RsRegularExpression::Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags)
{
return mFileDatabase->SearchBoolExp(exp, results,flags,RsPeerId());
}
int ftServer::SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id)
int ftServer::SearchBoolExp(RsRegularExpression::Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id)
{
return mFileDatabase->SearchBoolExp(exp,results,flags,peer_id) ;
}

View File

@ -184,8 +184,8 @@ public:
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags);
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id);
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags);
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id);
virtual int SearchBoolExp(RsRegularExpression::Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags);
virtual int SearchBoolExp(RsRegularExpression::Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id);
/***
* Utility Functions

View File

@ -59,6 +59,7 @@ file_lists {
file_sharing/rsfilelistitems.cc
}
dsdv {
DEFINES *= SERVICES_DSDV
HEADERS += services/p3dsdv.h \

View File

@ -1,6 +1,3 @@
#ifndef RS_EXPRESSIONS_H
#define RS_EXPRESSIONS_H
/*
* rs-core/src/rsiface: rsexpr.h
*
@ -26,16 +23,19 @@
*
*/
#pragma once
#include <string>
#include <list>
#include <stdint.h>
#include "retroshare/rstypes.h"
/******************************************************************************************
Enumerations defining the Operators usable in the Boolean search expressions
******************************************************************************************/
namespace RsRegularExpression
{
enum LogicalOperator{
AndOp=0, /* exp AND exp */
OrOp=1, /* exp OR exp */
@ -50,7 +50,7 @@ enum StringOperator{
EqualsString = 2 /* exactly equal*/
};
/*Relational operators ( >, <, >=, <=, == and InRange )*/
/* Comparison operators ( >, <, >=, <=, == and InRange ) */
enum RelOperator{
Equals = 0,
GreaterEquals = 1,
@ -105,25 +105,37 @@ classes:
******************************************************************************************/
class FileEntry;
/*!
* \brief The ExpFileEntry class
* This is the base class the regular expressions can operate on. Derive it to fit your own needs!
*/
class ExpFileEntry
{
public:
virtual const std::string& file_name() const =0;
virtual uint64_t file_size() const =0;
virtual time_t file_modtime() const =0;
virtual time_t file_popularity() const =0;
virtual const std::string file_parent_path() const =0;
virtual const RsFileHash& file_hash() const =0;
};
class Expression
{
public:
virtual bool eval (FileEntry *file) = 0;
virtual bool eval (const ExpFileEntry& file) = 0;
virtual ~Expression() {};
virtual void linearize(LinearizedExpression& e) const = 0 ;
};
class CompoundExpression : public Expression
{
public:
CompoundExpression( enum LogicalOperator op, Expression * exp1, Expression *exp2)
: Lexp(exp1), Rexp(exp2), Op(op){ }
bool eval (FileEntry *file) {
bool eval (const ExpFileEntry& file) {
if (Lexp == NULL or Rexp == NULL) {
return false;
}
@ -231,7 +243,7 @@ class NameExpression: public StringExpression
public:
NameExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
StringExpression(op,t,ic) {}
bool eval(FileEntry *file);
bool eval(const ExpFileEntry& file);
virtual void linearize(LinearizedExpression& e) const
{
@ -244,7 +256,7 @@ class PathExpression: public StringExpression {
public:
PathExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
StringExpression(op,t,ic) {}
bool eval(FileEntry *file);
bool eval(const ExpFileEntry& file);
virtual void linearize(LinearizedExpression& e) const
{
@ -257,7 +269,7 @@ class ExtExpression: public StringExpression {
public:
ExtExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
StringExpression(op,t,ic) {}
bool eval(FileEntry *file);
bool eval(const ExpFileEntry& file);
virtual void linearize(LinearizedExpression& e) const
{
@ -270,7 +282,7 @@ class HashExpression: public StringExpression {
public:
HashExpression(enum StringOperator op, std::list<std::string> &t):
StringExpression(op,t, true) {}
bool eval(FileEntry *file);
bool eval(const ExpFileEntry& file);
virtual void linearize(LinearizedExpression& e) const
{
@ -290,7 +302,7 @@ class DateExpression: public RelExpression<int>
DateExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
DateExpression(enum RelOperator op, int lv, int hv):
RelExpression<int>(op,lv,hv) {}
bool eval(FileEntry *file);
bool eval(const ExpFileEntry& file);
virtual void linearize(LinearizedExpression& e) const
{
@ -305,7 +317,7 @@ class SizeExpression: public RelExpression<int>
SizeExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
SizeExpression(enum RelOperator op, int lv, int hv):
RelExpression<int>(op,lv,hv) {}
bool eval(FileEntry *file);
bool eval(const ExpFileEntry& file);
virtual void linearize(LinearizedExpression& e) const
{
@ -320,7 +332,7 @@ class SizeExpressionMB: public RelExpression<int>
SizeExpressionMB(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
SizeExpressionMB(enum RelOperator op, int lv, int hv):
RelExpression<int>(op,lv,hv) {}
bool eval(FileEntry *file);
bool eval(const ExpFileEntry& file);
virtual void linearize(LinearizedExpression& e) const
{
@ -334,7 +346,7 @@ class PopExpression: public RelExpression<int>
PopExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
PopExpression(enum RelOperator op, int lv, int hv): RelExpression<int>(op,lv,hv) {}
PopExpression(const LinearizedExpression& e) ;
bool eval(FileEntry *file);
bool eval(const ExpFileEntry& file);
virtual void linearize(LinearizedExpression& e) const
{
@ -342,6 +354,6 @@ class PopExpression: public RelExpression<int>
RelExpression<int>::linearize(e) ;
}
};
}
#endif /* RS_EXPRESSIONS_H */

View File

@ -36,7 +36,7 @@
class RsFiles;
extern RsFiles *rsFiles;
class Expression;
namespace RsRegularExpression { class Expression; }
class CacheStrapper ;
class CacheTransfer;
@ -190,8 +190,8 @@ class RsFiles
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags) = 0;
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0;
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags) = 0;
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0;
virtual int SearchBoolExp(RsRegularExpression::Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags) = 0;
virtual int SearchBoolExp(RsRegularExpression::Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0;
/***
* Utility Functions.

View File

@ -35,7 +35,7 @@
#include "retroshare/rstypes.h"
class LinearizedExpression ;
namespace RsRegularExpression { class LinearizedExpression ; }
class RsTurtleClientService ;
class RsTurtle;
@ -102,7 +102,7 @@ class RsTurtle
// as they come back.
//
virtual TurtleRequestId turtleSearch(const std::string& match_string) = 0 ;
virtual TurtleRequestId turtleSearch(const LinearizedExpression& expr) = 0 ;
virtual TurtleRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) = 0 ;
// Initiates tunnel handling for the given file hash. tunnels. Launches
// an exception if an error occurs during the initialization process. The

View File

@ -1763,7 +1763,7 @@ void RsTurtleRegExpSearchRequestItem::performLocalSearch(std::list<TurtleFileInf
std::list<DirDetails> initialResults;
// to do: split search string into words.
Expression *exp = LinearizedExpression::toExpr(expr) ;
RsRegularExpression::Expression *exp = RsRegularExpression::LinearizedExpression::toExpr(expr) ;
if(exp == NULL)
return ;
@ -1820,7 +1820,7 @@ TurtleRequestId p3turtle::turtleSearch(const std::string& string_to_match)
return id ;
}
TurtleRequestId p3turtle::turtleSearch(const LinearizedExpression& expr)
TurtleRequestId p3turtle::turtleSearch(const RsRegularExpression::LinearizedExpression& expr)
{
// generate a new search id.

View File

@ -239,7 +239,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
// remove the specific file search packets from the turtle router.
//
virtual TurtleSearchRequestId turtleSearch(const std::string& string_to_match) ;
virtual TurtleSearchRequestId turtleSearch(const LinearizedExpression& expr) ;
virtual TurtleSearchRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ;
// Initiates tunnel handling for the given file hash. tunnels. Launches
// an exception if an error occurs during the initialization process. The

View File

@ -102,7 +102,7 @@ class RsTurtleRegExpSearchRequestItem: public RsTurtleSearchRequestItem
RsTurtleRegExpSearchRequestItem() : RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_REGEXP_SEARCH_REQUEST) {}
RsTurtleRegExpSearchRequestItem(void *data,uint32_t size) ;
LinearizedExpression expr ; // Reg Exp in linearised mode
RsRegularExpression::LinearizedExpression expr ; // Reg Exp in linearised mode
virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleRegExpSearchRequestItem(*this) ; }
virtual void performLocalSearch(std::list<TurtleFileInfo>&) const ;

View File

@ -774,7 +774,7 @@ void SearchDialog::initSearchResult(const QString& txt, qulonglong searchId, int
ui.searchSummaryWidget->setCurrentItem(item2);
}
void SearchDialog::advancedSearch(Expression* expression)
void SearchDialog::advancedSearch(RsRegularExpression::Expression* expression)
{
advSearchDialog->hide();
@ -782,7 +782,7 @@ void SearchDialog::advancedSearch(Expression* expression)
std::list<DirDetails> results;
// send a turtle search request
LinearizedExpression e ;
RsRegularExpression::LinearizedExpression e ;
expression->linearize(e) ;
TurtleRequestId req_id = rsTurtle->turtleSearch(e) ;
@ -843,8 +843,8 @@ void SearchDialog::searchKeywords(const QString& keywords)
if (n < 1)
return;
NameExpression exprs(ContainsAllStrings,words,true) ;
LinearizedExpression lin_exp ;
RsRegularExpression::NameExpression exprs(RsRegularExpression::ContainsAllStrings,words,true) ;
RsRegularExpression::LinearizedExpression lin_exp ;
exprs.linearize(lin_exp) ;
TurtleRequestId req_id ;

View File

@ -27,9 +27,10 @@
#include "mainpage.h"
class AdvancedSearchDialog;
class Expression;
class RSTreeWidgetItemCompareRole;
namespace RsRegularExpression { class Expression; }
#define FRIEND_SEARCH 1
#define ANONYMOUS_SEARCH 2
class SearchDialog : public MainPage
@ -99,7 +100,7 @@ private slots:
void showAdvSearchDialog(bool=true);
/** perform the advanced search */
void advancedSearch(Expression*);
void advancedSearch(RsRegularExpression::Expression*);
void selectSearchResults(int index = -1);
void hideOrShowSearchResult(QTreeWidgetItem* resultItem, QString currentSearchId = QString(), int fileTypeIndex = -1);

View File

@ -119,9 +119,9 @@ void AdvancedSearchDialog::prepareSearch()
}
Expression * AdvancedSearchDialog::getRsExpr()
RsRegularExpression::Expression * AdvancedSearchDialog::getRsExpr()
{
Expression * wholeExpression;
RsRegularExpression::Expression * wholeExpression;
// process the special case: first expression
wholeExpression = expressions->at(0)->getRsExpression();
@ -131,7 +131,7 @@ Expression * AdvancedSearchDialog::getRsExpr()
for (int i = 1; i < expressions->size(); ++i) {
// extract the expression information and compound it with the
// first expression
wholeExpression = new CompoundExpression(expressions->at(i)->getOperator(),
wholeExpression = new RsRegularExpression::CompoundExpression(expressions->at(i)->getOperator(),
wholeExpression,
expressions->at(i)->getRsExpression());
}

View File

@ -36,10 +36,10 @@ class AdvancedSearchDialog : public QDialog, public Ui::AdvancedSearchDialog
public:
AdvancedSearchDialog(QWidget * parent = 0 );
Expression * getRsExpr();
RsRegularExpression::Expression * getRsExpr();
QString getSearchAsString();
signals:
void search(Expression*);
void search(RsRegularExpression::Expression*);
private slots:
void deleteExpression(ExpressionWidget*);

View File

@ -130,7 +130,7 @@ void ExpressionWidget::deleteExpression()
emit signalDelete(this);
}
LogicalOperator ExpressionWidget::getOperator()
RsRegularExpression::LogicalOperator ExpressionWidget::getOperator()
{
return exprOpElem->getLogicalOperator();
}
@ -145,9 +145,9 @@ static int checkedConversion(uint64_t s)
return (int)s ;
}
Expression* ExpressionWidget::getRsExpression()
RsRegularExpression::Expression* ExpressionWidget::getRsExpression()
{
Expression * expr = NULL;
RsRegularExpression::Expression * expr = NULL;
std::list<std::string> wordList;
uint64_t lowVal = 0;
@ -174,54 +174,54 @@ Expression* ExpressionWidget::getRsExpression()
switch (searchType)
{
case NameSearch:
expr = new NameExpression(exprCondElem->getStringOperator(),
expr = new RsRegularExpression::NameExpression(exprCondElem->getStringOperator(),
wordList,
exprParamElem->ignoreCase());
break;
case PathSearch:
expr = new PathExpression(exprCondElem->getStringOperator(),
expr = new RsRegularExpression::PathExpression(exprCondElem->getStringOperator(),
wordList,
exprParamElem->ignoreCase());
break;
case ExtSearch:
expr = new ExtExpression(exprCondElem->getStringOperator(),
expr = new RsRegularExpression::ExtExpression(exprCondElem->getStringOperator(),
wordList,
exprParamElem->ignoreCase());
break;
case HashSearch:
expr = new HashExpression(exprCondElem->getStringOperator(),
expr = new RsRegularExpression::HashExpression(exprCondElem->getStringOperator(),
wordList);
break;
case DateSearch:
if (inRangedConfig) {
expr = new DateExpression(exprCondElem->getRelOperator(), checkedConversion(lowVal), checkedConversion(highVal));
expr = new RsRegularExpression::DateExpression(exprCondElem->getRelOperator(), checkedConversion(lowVal), checkedConversion(highVal));
} else {
expr = new DateExpression(exprCondElem->getRelOperator(), checkedConversion(exprParamElem->getIntValue()));
expr = new RsRegularExpression::DateExpression(exprCondElem->getRelOperator(), checkedConversion(exprParamElem->getIntValue()));
}
break;
case PopSearch:
if (inRangedConfig) {
expr = new DateExpression(exprCondElem->getRelOperator(), checkedConversion(lowVal), checkedConversion(highVal));
expr = new RsRegularExpression::DateExpression(exprCondElem->getRelOperator(), checkedConversion(lowVal), checkedConversion(highVal));
} else {
expr = new DateExpression(exprCondElem->getRelOperator(), checkedConversion(exprParamElem->getIntValue()));
expr = new RsRegularExpression::DateExpression(exprCondElem->getRelOperator(), checkedConversion(exprParamElem->getIntValue()));
}
break;
case SizeSearch:
if (inRangedConfig)
{
if(lowVal >= (uint64_t)(1024*1024*1024) || highVal >= (uint64_t)(1024*1024*1024))
expr = new SizeExpressionMB(exprCondElem->getRelOperator(), (int)(lowVal / (1024*1024)), (int)(highVal / (1024*1024)));
expr = new RsRegularExpression::SizeExpressionMB(exprCondElem->getRelOperator(), (int)(lowVal / (1024*1024)), (int)(highVal / (1024*1024)));
else
expr = new SizeExpression(exprCondElem->getRelOperator(), lowVal, highVal);
expr = new RsRegularExpression::SizeExpression(exprCondElem->getRelOperator(), lowVal, highVal);
}
else
{
uint64_t s = exprParamElem->getIntValue() ;
if(s >= (uint64_t)(1024*1024*1024))
expr = new SizeExpressionMB(exprCondElem->getRelOperator(), (int)(s/(1024*1024))) ;
expr = new RsRegularExpression::SizeExpressionMB(exprCondElem->getRelOperator(), (int)(s/(1024*1024))) ;
else
expr = new SizeExpression(exprCondElem->getRelOperator(), (int)s) ;
expr = new RsRegularExpression::SizeExpression(exprCondElem->getRelOperator(), (int)s) ;
}
break;
};

View File

@ -45,11 +45,11 @@ public:
/** delivers the expression represented by this widget
the operator to join this expression with any previous
expressions is provided by the getOperator method */
Expression* getRsExpression();
RsRegularExpression::Expression* getRsExpression();
/** supplies the operator to be used when joining this expression
to the whole query */
LogicalOperator getOperator();
RsRegularExpression::LogicalOperator getOperator();
QString toString();

View File

@ -62,9 +62,9 @@ QStringList GuiExprElement::relOptionsList;
QMap<int, ExprSearchType> GuiExprElement::TermsIndexMap;
QMap<int, LogicalOperator> GuiExprElement::logicalOpIndexMap;
QMap<int, StringOperator> GuiExprElement::strConditionIndexMap;
QMap<int, RelOperator> GuiExprElement::relConditionIndexMap;
QMap<int, RsRegularExpression::LogicalOperator> GuiExprElement::logicalOpIndexMap;
QMap<int, RsRegularExpression::StringOperator> GuiExprElement::strConditionIndexMap;
QMap<int, RsRegularExpression::RelOperator> GuiExprElement::relConditionIndexMap;
QMap<int, QString> GuiExprElement::logicalOpStrMap;
QMap<int, QString> GuiExprElement::termsStrMap;
@ -141,9 +141,9 @@ void GuiExprElement::initialiseOptionsLists()
GuiExprElement::relOptionsList.append(RANGE);
// now the maps
GuiExprElement::logicalOpIndexMap[GuiExprElement::AND_INDEX] = AndOp;
GuiExprElement::logicalOpIndexMap[GuiExprElement::OR_INDEX] = OrOp;
GuiExprElement::logicalOpIndexMap[GuiExprElement::XOR_INDEX] = XorOp;
GuiExprElement::logicalOpIndexMap[GuiExprElement::AND_INDEX] = RsRegularExpression::AndOp;
GuiExprElement::logicalOpIndexMap[GuiExprElement::OR_INDEX] = RsRegularExpression::OrOp;
GuiExprElement::logicalOpIndexMap[GuiExprElement::XOR_INDEX] = RsRegularExpression::XorOp;
GuiExprElement::TermsIndexMap[GuiExprElement::NAME_INDEX] = NameSearch;
GuiExprElement::TermsIndexMap[GuiExprElement::PATH_INDEX] = PathSearch;
@ -153,9 +153,9 @@ void GuiExprElement::initialiseOptionsLists()
GuiExprElement::TermsIndexMap[GuiExprElement::SIZE_INDEX] = SizeSearch;
GuiExprElement::TermsIndexMap[GuiExprElement::POP_INDEX] = PopSearch;
GuiExprElement::strConditionIndexMap[GuiExprElement::CONTAINS_INDEX] = ContainsAnyStrings;
GuiExprElement::strConditionIndexMap[GuiExprElement::CONTALL_INDEX] = ContainsAllStrings;
GuiExprElement::strConditionIndexMap[GuiExprElement::IS_INDEX] = EqualsString;
GuiExprElement::strConditionIndexMap[GuiExprElement::CONTAINS_INDEX] = RsRegularExpression::ContainsAnyStrings;
GuiExprElement::strConditionIndexMap[GuiExprElement::CONTALL_INDEX] = RsRegularExpression::ContainsAllStrings;
GuiExprElement::strConditionIndexMap[GuiExprElement::IS_INDEX] = RsRegularExpression::EqualsString;
/* W A R N I N G !!!!
the cb elements correspond to their inverse rel op counterparts in rsexpr.h due to the nature of
@ -166,12 +166,12 @@ void GuiExprElement::initialiseOptionsLists()
files where the condition is greater than the file size i.e. files whose size is less than or equal to the condition
Therefore we invert the mapping of rel conditions here to match the behaviour of the impl.
*/
GuiExprElement::relConditionIndexMap[GuiExprElement::LT_INDEX] = GreaterEquals;
GuiExprElement::relConditionIndexMap[GuiExprElement::LTE_INDEX] = Greater;
GuiExprElement::relConditionIndexMap[GuiExprElement::EQUAL_INDEX] = Equals;
GuiExprElement::relConditionIndexMap[GuiExprElement::GTE_INDEX] = Smaller;
GuiExprElement::relConditionIndexMap[GuiExprElement::GT_INDEX] = SmallerEquals;
GuiExprElement::relConditionIndexMap[GuiExprElement::RANGE_INDEX] = InRange;
GuiExprElement::relConditionIndexMap[GuiExprElement::LT_INDEX] = RsRegularExpression::GreaterEquals;
GuiExprElement::relConditionIndexMap[GuiExprElement::LTE_INDEX] = RsRegularExpression::Greater;
GuiExprElement::relConditionIndexMap[GuiExprElement::EQUAL_INDEX] = RsRegularExpression::Equals;
GuiExprElement::relConditionIndexMap[GuiExprElement::GTE_INDEX] = RsRegularExpression::Smaller;
GuiExprElement::relConditionIndexMap[GuiExprElement::GT_INDEX] = RsRegularExpression::SmallerEquals;
GuiExprElement::relConditionIndexMap[GuiExprElement::RANGE_INDEX] = RsRegularExpression::InRange;
// the string to index map
GuiExprElement::termsStrMap[GuiExprElement::NAME_INDEX] = NAME;
@ -260,7 +260,7 @@ QString ExprOpElement::toString()
}
LogicalOperator ExprOpElement::getLogicalOperator()
RsRegularExpression::LogicalOperator ExprOpElement::getLogicalOperator()
{
return GuiExprElement::logicalOpIndexMap[cb->currentIndex()];
}
@ -313,12 +313,12 @@ QString ExprConditionElement::toString()
return GuiExprElement::relConditionStrMap[cb->currentIndex()];
}
RelOperator ExprConditionElement::getRelOperator()
RsRegularExpression::RelOperator ExprConditionElement::getRelOperator()
{
return GuiExprElement::relConditionIndexMap[cb->currentIndex()];
}
StringOperator ExprConditionElement::getStringOperator()
RsRegularExpression::StringOperator ExprConditionElement::getStringOperator()
{
return GuiExprElement::strConditionIndexMap[cb->currentIndex()];
}

View File

@ -114,9 +114,9 @@ protected:
static QStringList relOptionsList;
// provides a mapping of condition operators to RSExpr reloperators
static QMap<int, LogicalOperator> logicalOpIndexMap;
static QMap<int, StringOperator> strConditionIndexMap;
static QMap<int, RelOperator> relConditionIndexMap;
static QMap<int, RsRegularExpression::LogicalOperator> logicalOpIndexMap;
static QMap<int, RsRegularExpression::StringOperator> strConditionIndexMap;
static QMap<int, RsRegularExpression::RelOperator> relConditionIndexMap;
// provides a mapping of indexes to translatable strings
static QMap<int, QString> logicalOpStrMap;
@ -134,7 +134,7 @@ class ExprOpElement : public GuiExprElement
public:
ExprOpElement(QWidget * parent = 0);
LogicalOperator getLogicalOperator();
RsRegularExpression::LogicalOperator getLogicalOperator();
QString toString();
private:
QComboBox * cb;
@ -148,8 +148,8 @@ class ExprTermsElement : public GuiExprElement
public:
ExprTermsElement(QWidget * parent = 0);
int getTermsIndex();
RelOperator getRelOperator();
StringOperator getStringOperator();
RsRegularExpression::RelOperator getRelOperator();
RsRegularExpression::StringOperator getStringOperator();
void set(int i) {cb->setCurrentIndex(i);}
QString toString();
@ -167,8 +167,8 @@ class ExprConditionElement : public GuiExprElement
public:
ExprConditionElement(ExprSearchType, QWidget * parent = 0);
RelOperator getRelOperator();
StringOperator getStringOperator();
RsRegularExpression::RelOperator getRelOperator();
RsRegularExpression::StringOperator getStringOperator();
void adjustForSearchType(ExprSearchType);
void set(int i) {cb->setCurrentIndex(i);}
QString toString();