Skip to content

Commit

Permalink
#1303 Return original format
Browse files Browse the repository at this point in the history
Fix ex=rror in indigo-ketcher.cpp
  • Loading branch information
AliaksandrDziarkach committed Oct 10, 2023
1 parent e0d0eed commit 15e86bd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions api/wasm/indigo-ketcher/indigo-ketcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace indigo
std::string toString(const std::map<std::string, std::string>& options, const std::string& outputFormat) const
{
print_js("toString:");
cstring result = nullptr;
std::string result;
if (outputFormat == "molfile" || outputFormat == "rxnfile" || outputFormat == "chemical/x-mdl-molfile" || outputFormat == "chemical/x-mdl-rxnfile")
{
if (is_reaction())
Expand Down Expand Up @@ -187,21 +187,22 @@ namespace indigo
print_js(outputFormat.c_str());
result = _checkResultString(indigoToString(buffer.id));
}
if (result == nullptr)
else
{
std::stringstream ss;
ss << "Unknown output format: " << outputFormat;
jsThrow(ss.str().c_str());
return ""; // suppress warning
}
if (auto out = options.find("output-content-type"); out != options.end() && out->second == "application/json")
auto out = options.find("output-content-type");
if (out != options.end() && out->second == "application/json")
{
cstring originalFormat = _checkResultString(indigoGetOriginalFormat(id()));
std::string originalFormat = _checkResultString(indigoGetOriginalFormat(id()));
rapidjson::Document resultJson;
auto& allocator = resultJson.GetAllocator();
resultJson.SetObject();
resultJson.AddMember("struct", result, allocator);
resultJson.AddMember("format", outputFormat.c_str(), allocator);
resultJson.AddMember("format", outputFormat, allocator);
resultJson.AddMember("original_format", originalFormat, allocator);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
Expand Down Expand Up @@ -302,8 +303,8 @@ namespace indigo
exceptionMessages.reserve(4);

int objectId = -1;
if (auto input_format = options.find("input-format");
input_format != options.end() && (input_format->second == "smarts" || input_format->second == "chemical/x-daylight-smarts"))
auto input_format = options.find("input-format");
if (input_format != options.end() && (input_format->second == "smarts" || input_format->second == "chemical/x-daylight-smarts"))
{
print_js("load as smarts");
objectId = indigoLoadSmartsFromBuffer(data.c_str(), data.size());
Expand Down

0 comments on commit 15e86bd

Please sign in to comment.