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