OpenLexocad  27.1
PropertyString.h
Go to the documentation of this file.
1 #pragma once
2 #pragma warning(disable : 4251)
3 #include <Core/Property.h>
4 #include <Core/Variant.h>
5 
6 #include <QRegExp>
7 #include <string>
8 
9 namespace Core
10 {
11 // This pattern is used to remove all characters not valid in XML 1.0 from text before saving.
12 // Without this, saved document cannot be loaded.
13 // (User is able to enter invalid character for example using clipboard.)
14 // Adopted from original here: http://stackoverflow.com/questions/4237625/removing-invalid-xml-characters-from-a-string-in-java
15 // -mh-2016-03-18
16 static QRegExp xml10TextValidityPattern = QRegExp("[^\\x0009\\r\\n\\x0020-\\xD7FF\\xE000-\\xFFFD\\xd800\\xdc00-\\xdbff\\xdfff]");
17 
18 
19 class LX_CORE_EXPORT PropertyString : public Core::Property
20 {
22 
23 public:
24  PropertyString(void);
25  virtual ~PropertyString(void);
26 
27  // void setValue(const std::string& text);
28  bool setValue(const Base::String& text);
29  bool setValueFromVariant(const Core::Variant& value);
30  void copyValue(Core::Property* p);
31 
32  const Base::String& getValue() const;
33  Core::Variant getVariant(void) const;
34 
35  virtual void save(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version);
36  virtual bool createSQL(Base::AbstractWriter& writer, Base::PersistenceVersion& save_version, bool data) override;
37  inline virtual void restore(Base::AbstractXMLReader& reader, Base::PersistenceVersion& version);
38  virtual bool isEqual(const Property*) const;
39  virtual Core::Property* copy(void) const override;
40  virtual void paste(const Core::Property& from) override;
41 
42 protected:
44 };
45 
47 DECLARE_PROPERTY_FACTORY(PropertyString_Factory, Core::PropertyString);
48 
49 
50 
51 } // namespace Core
DECLARE_OPTIONAL_PROPERTY_HEADER(PropertyColorOpt, Core::PropertyColor)
Definition: Persistence.h:14
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:23
LX_CORE_EXPORT Version & version
Base::String _text
Definition: PropertyString.h:43
Definition: Variant.h:87
Definition: AbstractXMLReader.h:7
Definition: Base.h:12
Definition: Writer.h:16
Definition: Property.h:77
TYPESYSTEM_HEADER()
Definition: PropertyString.h:19
DECLARE_PROPERTY_FACTORY(PropertyAxis1_Factory, Core::PropertyAxis1)