moved code around to make smallut and pathut less recoll-specific and reusable. No actual changes
This commit is contained in:
@@ -42,6 +42,7 @@ using namespace std;
|
||||
#include "unacpp.h"
|
||||
#include "conftree.h"
|
||||
#include "pathut.h"
|
||||
#include "rclutil.h"
|
||||
#include "smallut.h"
|
||||
#include "chrono.h"
|
||||
#include "utf8iter.h"
|
||||
@@ -126,6 +127,21 @@ static inline string make_parentterm(const string& udi)
|
||||
return pterm;
|
||||
}
|
||||
|
||||
static void utf8truncate(string& s, int maxlen)
|
||||
{
|
||||
if (s.size() <= string::size_type(maxlen)) {
|
||||
return;
|
||||
}
|
||||
Utf8Iter iter(s);
|
||||
string::size_type pos = 0;
|
||||
while (iter++ != string::npos)
|
||||
if (iter.getBpos() < string::size_type(maxlen)) {
|
||||
pos = iter.getBpos();
|
||||
}
|
||||
|
||||
s.erase(pos);
|
||||
}
|
||||
|
||||
Db::Native::Native(Db *db)
|
||||
: m_rcldb(db), m_isopen(false), m_iswritable(false),
|
||||
m_noversionwrite(false)
|
||||
|
||||
@@ -14,9 +14,11 @@
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include "rcldoc.h"
|
||||
#include "debuglog.h"
|
||||
#include "rclutil.h"
|
||||
|
||||
namespace Rcl {
|
||||
const string Doc::keyabs("abstract");
|
||||
@@ -70,5 +72,31 @@ namespace Rcl {
|
||||
if (dotext)
|
||||
LOGDEB(("Rcl::Doc::dump: text: \n[%s]\n", text.c_str()));
|
||||
}
|
||||
|
||||
// Copy ensuring no shared string data, for threading issues.
|
||||
void Doc::copyto(Doc *d) const
|
||||
{
|
||||
d->url.assign(url.begin(), url.end());
|
||||
d->idxurl.assign(idxurl.begin(), idxurl.end());
|
||||
d->idxi = idxi;
|
||||
d->ipath.assign(ipath.begin(), ipath.end());
|
||||
d->mimetype.assign(mimetype.begin(), mimetype.end());
|
||||
d->fmtime.assign(fmtime.begin(), fmtime.end());
|
||||
d->dmtime.assign(dmtime.begin(), dmtime.end());
|
||||
d->origcharset.assign(origcharset.begin(), origcharset.end());
|
||||
map_ss_cp_noshr(meta, &d->meta);
|
||||
d->syntabs = syntabs;
|
||||
d->pcbytes.assign(pcbytes.begin(), pcbytes.end());
|
||||
d->fbytes.assign(fbytes.begin(), fbytes.end());
|
||||
d->dbytes.assign(dbytes.begin(), dbytes.end());
|
||||
d->sig.assign(sig.begin(), sig.end());
|
||||
d->text.assign(text.begin(), text.end());
|
||||
d->pc = pc;
|
||||
d->xdocid = xdocid;
|
||||
d->idxi = idxi;
|
||||
d->haspages = haspages;
|
||||
d->haschildren = haschildren;
|
||||
d->onlyxattr = onlyxattr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-25
@@ -163,33 +163,11 @@ class Doc {
|
||||
onlyxattr = false;
|
||||
}
|
||||
// Copy ensuring no shared string data, for threading issues.
|
||||
void copyto(Doc *d) const {
|
||||
d->url.assign(url.begin(), url.end());
|
||||
d->idxurl.assign(idxurl.begin(), idxurl.end());
|
||||
d->idxi = idxi;
|
||||
d->ipath.assign(ipath.begin(), ipath.end());
|
||||
d->mimetype.assign(mimetype.begin(), mimetype.end());
|
||||
d->fmtime.assign(fmtime.begin(), fmtime.end());
|
||||
d->dmtime.assign(dmtime.begin(), dmtime.end());
|
||||
d->origcharset.assign(origcharset.begin(), origcharset.end());
|
||||
map_ss_cp_noshr(meta, &d->meta);
|
||||
d->syntabs = syntabs;
|
||||
d->pcbytes.assign(pcbytes.begin(), pcbytes.end());
|
||||
d->fbytes.assign(fbytes.begin(), fbytes.end());
|
||||
d->dbytes.assign(dbytes.begin(), dbytes.end());
|
||||
d->sig.assign(sig.begin(), sig.end());
|
||||
d->text.assign(text.begin(), text.end());
|
||||
d->pc = pc;
|
||||
d->xdocid = xdocid;
|
||||
d->idxi = idxi;
|
||||
d->haspages = haspages;
|
||||
d->haschildren = haschildren;
|
||||
d->onlyxattr = onlyxattr;
|
||||
}
|
||||
void copyto(Doc *d) const;
|
||||
|
||||
Doc()
|
||||
: idxi(0), syntabs(false), pc(0), xdocid(0),
|
||||
haspages(false), haschildren(false), onlyxattr(false)
|
||||
{
|
||||
haspages(false), haschildren(false), onlyxattr(false) {
|
||||
}
|
||||
/** Get value for named field. If value pointer is 0, just test existence */
|
||||
bool getmeta(const string& nm, string *value = 0) const
|
||||
|
||||
Reference in New Issue
Block a user