28 #include <angelscript.h>
30 using namespace AngelScript;
36 std::string log_msg =
"modcache.query(): ";
37 std::string search_expr;
42 int64_t i64_filter_category_id;
49 if (search_expr.find(
":") == std::string::npos)
56 Ogre::StringVector v = Ogre::StringUtil::split(search_expr,
":");
62 else if (v[0] ==
"guid")
67 else if (v[0] ==
"author")
72 else if (v[0] ==
"wheels")
77 else if (v[0] ==
"file")
90 size_t results_count =
self->Query(query);
95 CScriptArray* results_entries = CScriptArray::Create(typeinfo_array_entries);
96 CScriptArray* results_scores = CScriptArray::Create(typeinfo_array_scores);
100 results_entries->InsertLast(&entry_ptr);
101 results_scores->InsertLast(&result.
cqr_score);
104 CScriptDictionary* results_dict = CScriptDictionary::Create(
App::GetScriptEngine()->getEngine());
105 results_dict->Set(
"count", (asINT64)results_count);
106 results_dict->Set(
"entries", results_entries, typeinfo_array_entries->GetTypeId());
107 results_dict->Set(
"scores", results_scores, typeinfo_array_scores->GetTypeId());
114 CacheEntry::RegisterRefCountingObject(engine,
"CacheEntryClass");
115 CacheEntryPtr::RegisterRefCountingObjectPtr(engine,
"CacheEntryClassPtr",
"CacheEntryClass");
120 result = engine->RegisterEnum(
"LoaderType");
ROR_ASSERT(result >= 0);
121 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_NONE",
LT_None);
ROR_ASSERT(result >= 0);
122 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_TERRAIN",
LT_Terrain);
ROR_ASSERT(result >= 0);
123 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_VEHICLE",
LT_Vehicle);
ROR_ASSERT(result >= 0);
124 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_TRUCK",
LT_Truck);
ROR_ASSERT(result >= 0);
125 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_CAR",
LT_Car);
ROR_ASSERT(result >= 0);
126 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_BOAT",
LT_Boat);
ROR_ASSERT(result >= 0);
127 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_AIRPLANE",
LT_Airplane);
ROR_ASSERT(result >= 0);
128 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_TRAILER",
LT_Trailer);
ROR_ASSERT(result >= 0);
129 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_TRAIN",
LT_Train);
ROR_ASSERT(result >= 0);
130 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_LOAD",
LT_Load);
ROR_ASSERT(result >= 0);
131 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_EXTENSION",
LT_Extension);
ROR_ASSERT(result >= 0);
132 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_SKIN",
LT_Skin);
ROR_ASSERT(result >= 0);
133 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_ALLBEAM",
LT_AllBeam);
ROR_ASSERT(result >= 0);
138 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_fpath() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
const std::string& {
return self->fpath;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
139 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_fname() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
const std::string& {
return self->fname;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
140 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_fext() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
const std::string& {
return self->fext;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
141 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_dname() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
const std::string& {
return self->dname;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
142 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"int get_categoryid() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
int {
return self->categoryid;}, (
CacheEntry*),
int), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
143 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_categoryname() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
const std::string& {
return self->categoryname;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
144 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_resource_bundle_type() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
const std::string& {
return self->resource_bundle_type;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
145 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_resource_bundle_path() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
const std::string& {
return self->resource_bundle_path;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
146 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"int get_number() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
int {
return self->number;}, (
CacheEntry*),
int), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
147 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"bool get_deleted() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
bool {
return self->deleted;}, (
CacheEntry*),
bool), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
148 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_filecachename() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
const std::string& {
return self->filecachename;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
149 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_resource_group() const property", asFUNCTIONPR([](
CacheEntry*
self) ->
const std::string& {
return self->resource_group;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
152 result = engine->RegisterObjectType(
"CacheSystemClass",
sizeof(
CacheSystem), asOBJ_REF | asOBJ_NOCOUNT);
ROR_ASSERT(result>=0);
153 result = engine->RegisterObjectMethod(
"CacheSystemClass",
"CacheEntryClassPtr @findEntryByFilename(LoaderType, bool, const string &in)", asMETHOD(
CacheSystem,FindEntryByFilename), asCALL_THISCALL);
ROR_ASSERT(result>=0);
154 result = engine->RegisterObjectMethod(
"CacheSystemClass",
"CacheEntryClassPtr @getEntryByNumber(int)", asMETHOD(
CacheSystem,GetEntryByNumber), asCALL_THISCALL);
ROR_ASSERT(result>=0);
155 result = engine->RegisterObjectMethod(
"CacheSystemClass",
"dictionary@ query(dictionary@)", asFUNCTION(
CacheSystemQueryWrapper), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);