comparison OrthancServer/DatabaseWrapper.cpp @ 310:6ab6cdeedf4e

global sequences
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 21 Dec 2012 11:18:27 +0100
parents 4eea080e6e7a
children 42e87c17cab8
comparison
equal deleted inserted replaced
309:ee97f0923ddd 310:6ab6cdeedf4e
864 else 864 else
865 { 865 {
866 // Nothing to do: The patient is already unprotected 866 // Nothing to do: The patient is already unprotected
867 } 867 }
868 } 868 }
869
870
871 uint64_t DatabaseWrapper::IncrementGlobalSequence(GlobalProperty property)
872 {
873 std::string oldValue;
874
875 if (LookupGlobalProperty(oldValue, property))
876 {
877 uint64_t oldNumber;
878
879 try
880 {
881 oldNumber = boost::lexical_cast<uint64_t>(oldValue);
882 SetGlobalProperty(property, boost::lexical_cast<std::string>(oldNumber + 1));
883 return oldNumber + 1;
884 }
885 catch (boost::bad_lexical_cast&)
886 {
887 throw OrthancException(ErrorCode_InternalError);
888 }
889 }
890 else
891 {
892 // Initialize the sequence at "1"
893 SetGlobalProperty(property, "1");
894 return 1;
895 }
896 }
869 } 897 }