Merge pull request #4 from CoatiSoftware/fix_examples
Fix examples for windows
This commit is contained in:
@@ -4,6 +4,17 @@
|
||||
|
||||
#include "SourcetrailDBWriter.h"
|
||||
|
||||
void findAndReplaceAll(std::string &data, const std::string &toSearch, const std::string &replaceStr)
|
||||
{
|
||||
size_t pos = data.find(toSearch);
|
||||
|
||||
while (pos != std::string::npos)
|
||||
{
|
||||
data.replace(pos, toSearch.size(), replaceStr);
|
||||
pos = data.find(toSearch, pos + replaceStr.size());
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
sourcetrail::SourcetrailDBWriter dbWriter;
|
||||
@@ -21,6 +32,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
std::string dbPath = argv[1];
|
||||
std::string sourcePath = argv[2];
|
||||
findAndReplaceAll(sourcePath, "\\", "/");
|
||||
|
||||
int dbVersion = 0;
|
||||
if (argc == 4)
|
||||
@@ -44,6 +56,13 @@ int main(int argc, const char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << "Clearing Database... " << std::endl;
|
||||
if (!dbWriter.clear())
|
||||
{
|
||||
std::cerr << "error: " << dbWriter.getLastError() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << "Starting Indexing..." << std::endl;
|
||||
|
||||
// start recording with faster speed
|
||||
@@ -83,7 +102,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
// record inheritance reference to "BaseType"
|
||||
int baseId = dbWriter.recordSymbol( { "::", { { "", "BaseType", "" } } } );
|
||||
int inheritanceId = dbWriter.recordReference(baseId, classId, sourcetrail::ReferenceKind::INHERITANCE);
|
||||
int inheritanceId = dbWriter.recordReference(classId, baseId, sourcetrail::ReferenceKind::INHERITANCE);
|
||||
dbWriter.recordReferenceLocation(inheritanceId, { fileId, 12, 14, 12, 21 });
|
||||
|
||||
|
||||
@@ -98,7 +117,7 @@ int main(int argc, const char *argv[])
|
||||
dbWriter.recordSymbolSignatureLocation(methodId, { fileId, 15, 5, 15, 45 }); // used in tooltip
|
||||
|
||||
|
||||
// record parameter type "bool"
|
||||
// record usage of parameter type "bool"
|
||||
int typeId = dbWriter.recordSymbol({ "::", { { "", "bool", "" } } });
|
||||
int typeuseId = dbWriter.recordReference(methodId, typeId, sourcetrail::ReferenceKind::TYPE_USAGE);
|
||||
dbWriter.recordReferenceLocation(typeuseId, { fileId, 15, 20, 15, 23 });
|
||||
|
||||
@@ -13,7 +13,7 @@ def main():
|
||||
|
||||
args = parser.parse_args()
|
||||
databaseFilePath = args.database_file_path
|
||||
sourceFilePath = args.source_file_path
|
||||
sourceFilePath = args.source_file_path.replace("\\", "/")
|
||||
dbVersion = args.database_version
|
||||
|
||||
print("SourcetrailDB Python API Example")
|
||||
@@ -28,10 +28,8 @@ def main():
|
||||
print("ERROR: " + srctrl.getLastError())
|
||||
return 1
|
||||
|
||||
if srctrl.isEmpty():
|
||||
print("Loaded database is empty.")
|
||||
else:
|
||||
print("Loaded database contains data.")
|
||||
print("Clearing loaded database now...")
|
||||
srctrl.clear()
|
||||
|
||||
print("start indexing")
|
||||
srctrl.beginTransaction()
|
||||
|
||||
Reference in New Issue
Block a user