add api usage examples for cpp and python binding
This commit is contained in:
committed by
Eberhard Graether
parent
4517be935c
commit
1c07e5b4dc
@@ -38,7 +38,7 @@ namespace sourcetrail
|
||||
|
||||
std::string serializeNameHierarchyToDatabaseString(const NameHierarchy& nameHierarchy);
|
||||
std::string serializeNameHierarchyToJson(const NameHierarchy& nameHierarchy);
|
||||
NameHierarchy deserializeNameHierarchyFromJson(const std::string& serializedNameHierarchy);
|
||||
NameHierarchy deserializeNameHierarchyFromJson(const std::string& serializedNameHierarchy, std::string* error = nullptr);
|
||||
}
|
||||
|
||||
#endif // SOURCETRAIL_NAME_HIERARCHY_H
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace sourcetrail
|
||||
|
||||
int getSupportedDatabaseVersion() const;
|
||||
const std::string& getLastError() const;
|
||||
void setLastError(const std::string& error) const;
|
||||
void clearLastError();
|
||||
|
||||
bool open(const std::string& databaseFilePath);
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace sourcetrail
|
||||
return j.dump(4);
|
||||
}
|
||||
|
||||
NameHierarchy deserializeNameHierarchyFromJson(const std::string& serializedNameHierarchy)
|
||||
NameHierarchy deserializeNameHierarchyFromJson(const std::string& serializedNameHierarchy, std::string* error)
|
||||
{
|
||||
typedef nlohmann::json json;
|
||||
|
||||
@@ -110,9 +110,19 @@ namespace sourcetrail
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (json::exception& e)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
*error = e.what();
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// do nothing
|
||||
if (error)
|
||||
{
|
||||
*error = "Exception thrown during NameHierarchy deserialization";
|
||||
}
|
||||
}
|
||||
|
||||
return nameHierarchy;
|
||||
|
||||
@@ -59,6 +59,11 @@ namespace sourcetrail
|
||||
return m_lastError;
|
||||
}
|
||||
|
||||
void SourcetrailDBWriter::setLastError(const std::string& error) const
|
||||
{
|
||||
m_lastError = error;
|
||||
}
|
||||
|
||||
void SourcetrailDBWriter::clearLastError()
|
||||
{
|
||||
m_lastError.clear();
|
||||
|
||||
Reference in New Issue
Block a user