diff Framework/Common/StatementId.cpp @ 581:a80775ee5eea find-refactoring

MySQL: Added support for ExtendedFind
author Alain Mazy <am@orthanc.team>
date Mon, 21 Oct 2024 14:34:57 +0200
parents 2ab3d45c0b3c
children
line wrap: on
line diff
--- a/Framework/Common/StatementId.cpp	Tue Oct 15 15:52:39 2024 +0200
+++ b/Framework/Common/StatementId.cpp	Mon Oct 21 14:34:57 2024 +0200
@@ -24,21 +24,31 @@
 #include "StatementId.h"
 
 #include <string.h>
+#include <Toolbox.h>
 
 namespace OrthancDatabases
 {
   bool StatementId::operator< (const StatementId& other) const
   {
-    if (line_ != other.line_)
-    {
-      return line_ < other.line_;
-    }
+    return hash_ < other.hash_;
+  }
+
+  StatementId::StatementId(const char* file,
+                           int line) :
+      file_(file),
+      line_(line)
+  {
+    Orthanc::Toolbox::ComputeMD5(hash_, file_ + boost::lexical_cast<std::string>(line_));
+  }
 
-    if (strcmp(file_, other.file_) < 0)
-    {
-      return true;
-    }
+  StatementId::StatementId(const char* file,
+                           int line,
+                           const std::string& statement) :
+      file_(file),
+      line_(line),
+      statement_(statement)
+  {
+    Orthanc::Toolbox::ComputeMD5(hash_, file_ + boost::lexical_cast<std::string>(line_) + statement_);
+  }
 
-    return statement_ < other.statement_;
-  }
 }