22 struct PropertyPersistenceInfo::Impl
30 std::string NameTemplate;
31 std::string KeyTemplate;
37 PropertyPersistenceInfo::Impl::Impl()
47 PropertyPersistenceInfo::Impl::~Impl() {}
61 m_Impl->MimeTypeName = mimeTypeName;
83 m_Impl->IsRegEx =
false;
84 m_Impl->NameTemplate.clear();
85 m_Impl->KeyTemplate.clear();
92 m_Impl->IsRegEx =
false;
93 m_Impl->NameTemplate.clear();
94 m_Impl->KeyTemplate.clear();
99 std::regex checker(nameRegEx);
100 m_Impl->Name = nameRegEx;
101 m_Impl->Key = nameRegEx;
102 m_Impl->IsRegEx =
true;
103 m_Impl->NameTemplate = nameTemplate;
104 m_Impl->KeyTemplate = nameTemplate;
108 const std::string &nameTemplate,
109 const std::string &keyRegEx,
110 const std::string keyTemplate)
112 std::regex nameChecker(nameRegEx);
113 std::regex keyChecker(keyRegEx);
114 m_Impl->Name = nameRegEx;
115 m_Impl->Key = keyRegEx;
116 m_Impl->IsRegEx =
true;
117 m_Impl->NameTemplate = nameTemplate;
118 m_Impl->KeyTemplate = keyTemplate;
123 return m_Impl->IsRegEx;
128 return m_Impl->KeyTemplate;
133 return m_Impl->NameTemplate;
138 return m_Impl->MimeTypeName;
143 m_Impl->MimeTypeName = mimeTypeName;
149 return m_Impl->DeSerFnc;
155 m_Impl->DeSerFnc = fnc;
161 return m_Impl->SerFnc;
167 m_Impl->SerFnc = fnc;
171 const std::string &templateStr,
172 const std::string ®exStr)
175 std::regex ex(regexStr);
176 std::regex_match(sourceStr, sm, ex);
178 std::string result = templateStr;
181 for (
const auto &match : sm)
185 std::ostringstream stream;
186 stream <<
"(\\$" << groupID <<
")";
187 std::regex rex(stream.str());
188 result = std::regex_replace(result, rex, match.str());
197 const std::string &propertyName)
const 200 *(resultInfo->m_Impl) = *(this->m_Impl);
205 resultInfo->SetNameAndKey(propertyName, newKey);
214 *(resultInfo->m_Impl) = *(this->m_Impl);
219 resultInfo->SetNameAndKey(newName, key);
233 this->Superclass::PrintSelf(os, indent);
235 os << indent <<
"Name: " << this->m_Impl->Name << std::endl;
236 os << indent <<
"Key: " << this->m_Impl->Key << std::endl;
237 os << indent <<
"IsRegEx: " << this->m_Impl->IsRegEx << std::endl;
238 os << indent <<
"NameTemplate: " << this->m_Impl->NameTemplate << std::endl;
239 os << indent <<
"KeyTemplate: " << this->m_Impl->KeyTemplate << std::endl;
240 os << indent <<
"MimeTypeName: " << this->m_Impl->MimeTypeName << std::endl;
251 std::string result =
"";
260 const std::string &value)
263 return result.GetPointer();
static MimeTypeNameType ANY_MIMETYPE_NAME()
const DeserializationFunctionType GetDeserializationFunction() const
std::string MimeTypeNameType
void SetSerializationFunction(const SerializationFunctionType &fnc)
MITKCORE_EXPORT::std::string serializeByGetValueAsString(const mitk::BaseProperty *prop)
DataCollection - Class to facilitate loading/accessing structured data.
const SerializationFunctionType GetSerializationFunction() const
~PropertyPersistenceInfo() override
MITKCORE_EXPORT mitk::BaseProperty::Pointer deserializeToStringProperty(const std::string &value)
static void info(const char *fmt,...)
PropertyPersistenceInfo::Pointer UnRegExByKey(const std::string &key) const
void PrintSelf(std::ostream &os, itk::Indent indent) const override
virtual std::string GetValueAsString() const
Abstract base class for properties.
Property persistence info. This class is used to specify the way the persistance of a property of Bas...
static std::string DEFAULT_BASE_NAME()
std::function< mitk::BaseProperty::Pointer(const std::string &)> DeserializationFunctionType
const MimeTypeNameType & GetMimeTypeName() const
void SetDeserializationFunction(const DeserializationFunctionType &fnc)
std::string GetKey() const
std::string GenerateFromTemplate(const std::string &sourceStr, const std::string &templateStr, const std::string ®exStr)
void SetName(const std::string &name)
const std::string & GetKeyTemplate() const
void SetMimeTypeName(const MimeTypeNameType &mimeTypeName)
PropertyPersistenceInfo(const std::string &name="")
Constructor.
const std::string & GetNameTemplate() const
void UseRegEx(const std::string &nameRegEx, const std::string &nameTemplate)
void SetNameAndKey(const std::string &name, const std::string &key)
std::function< std::string(const mitk::BaseProperty *)> SerializationFunctionType
std::string GetName() const
PropertyPersistenceInfo::Pointer UnRegExByName(const std::string &propertyName) const
MITKCORE_EXPORT std::ostream & operator<<(std::ostream &o, DataNode::Pointer &dtn)