OpenLexocad  28.0
PropertyString.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Core/Property.h>
4 #include <QRegExp>
5 
6 namespace Core
7 {
8 // This pattern is used to remove all characters not valid in XML 1.0 from text before saving.
9 // Without this, saved document cannot be loaded.
10 // (User is able to enter invalid character for example using clipboard.)
11 // Adopted from original here: http://stackoverflow.com/questions/4237625/removing-invalid-xml-characters-from-a-string-in-java
12 // -mh-2016-03-18
13 static QRegExp xml10TextValidityPattern = QRegExp("[^\\x0009\\r\\n\\x0020-\\xD7FF\\xE000-\\xFFFD\\xd800\\xdc00-\\xdbff\\xdfff]");
14 
15 // Jaroslaw: we need to store the line endings too, but it seems that the xml reader removes all line endings so we need to encode them
16 static QString lexocadLineBreakMark = QString("#LecoxadLineBreak#");
17 
18 
19 class LX_CORE_EXPORT PropertyString : public Core::Property
20 {
22 
23 public:
24  bool setValue(const Base::String& text);
25  bool setValueFromVariant(const Core::Variant& value);
27 
28  const Base::String& getValue() const;
30 
31  bool isEmpty() const;
32 
33  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
34  virtual bool createSQL(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version, bool data) override;
36  virtual bool isEqual(const Property*) const;
37  virtual Core::Property* copy(void) const override;
38  virtual void paste(const Core::Property& from) override;
39 
40 protected:
42 };
43 
46 
47 
48 
49 } // namespace Core
Property.h
Core::PropertyString::isEmpty
bool isEmpty() const
Core::PropertyString
Definition: PropertyString.h:20
Core::PropertyString::restore
virtual void restore(Base::AbstractXMLReader &reader, Base::PersistenceVersion &version)
This method is used to restore properties from an XML document.
Core::PropertyString::paste
virtual void paste(const Core::Property &from) override
Paste the value from the property (mainly for Undo/Redo and transactions)
Core::PropertyString::createSQL
virtual bool createSQL(Base::AbstractWriter &writer, Base::PersistenceVersion &save_version, bool data) override
This method is used to save properties or very small amounts of data to an XML document.
Core::PropertyString::isEqual
virtual bool isEqual(const Property *) const
compare properties
Core::PropertyString::getVariant
Core::Variant getVariant(void) const
Base::PersistenceVersion
Definition: Persistence.h:13
Core
Definition: Base.h:5
Core::Variant
Definition: Variant.h:78
Core::PropertyString::copyValue
void copyValue(Core::Property *p)
Base::AbstractWriter
Definition: Writer.h:13
Base::AbstractXMLReader
Definition: AbstractXMLReader.h:7
Core::PropertyString::copy
virtual Core::Property * copy(void) const override
Returns a new copy of the property (mainly for Undo/Redo and transactions). The copy has no container...
Core::PropertyString::save
virtual void save(Base::AbstractWriter &writer, Base::PersistenceVersion &save_version)
This method is used to save properties or very small amounts of data to an XML document.
Core::version
LX_CORE_EXPORT Version & version
Core::PropertyString::getValue
const Base::String & getValue() const
Core::PropertyString::setValueFromVariant
bool setValueFromVariant(const Core::Variant &value)
Core::Property
Definition: Property.h:72
Base::String
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:18
Core::PropertyString::_text
Base::String _text
Definition: PropertyString.h:41
Core::DECLARE_OPTIONAL_PROPERTY_HEADER
DECLARE_OPTIONAL_PROPERTY_HEADER(PropertyColorOpt, Core::PropertyColor)
TYPESYSTEM_HEADER
#define TYPESYSTEM_HEADER()
define for subclassing Base::BaseClass
Definition: Base.h:12
Core::DECLARE_PROPERTY_FACTORY
DECLARE_PROPERTY_FACTORY(PropertyAxis1_Factory, Core::PropertyAxis1)
Core::PropertyString::setValue
bool setValue(const Base::String &text)