2#include <NDEVR/Model.h>
4#include <NDEVR/Translator.h>
7 class ContactName :
public Model
10 ContactName(
const Model& model)
14 if (!isOfType(TypeName()))
17 setModelProperty(Model::e_type, TypeName());
20 void set(
const String& name)
22 setProperty(DesignObject::e_untranslated_string_data, name);
26 return getProperty<String>(DesignObject::e_untranslated_string_data);
28 static constexpr const char* ValidRegex() {
return "(\\w+)(\\.|_)?(\\w*)@(\\w+)(\\.(\\w+))+"; }
29 static constexpr const char* TypeName() {
return "contact_name"; }
31 class TelephoneNumber :
public Model
34 TelephoneNumber(
const Model& model)
37 if (!isOfType(TypeName()))
40 setModelProperty(Model::e_type, TypeName());
41 setProperty(Model::e_name,
_t(
"Mobile"));
42 setProperty(Model::e_icon,
"mobile");
45 String phoneNumber()
const
47 return getProperty<String>(DesignObject::e_untranslated_string_data);
49 void updatePhoneNumber(
const String& phone_number,
const void* lock_ptr =
nullptr)
51 updateProperty<String>(DesignObject::e_untranslated_string_data, phone_number, lock_ptr);
53 String phoneNumberName()
const
55 return getProperty<String>(DesignObject::e_name);
57 void updatePhoneNumberName(
const String& phone_number_name,
const void* lock_ptr =
nullptr)
59 updateProperty<String>(DesignObject::e_name, phone_number_name, lock_ptr);
61 static constexpr const char* ValidRegex() {
return "sad"; }
62 static constexpr const char* TypeName() {
return "telephone_number"; }
66 class PhysicalAddressModel :
public Model
69 PhysicalAddressModel(
const Model& model)
72 if (getModelProperty<String>(Model::e_type) != TypeName())
74 setModelProperty(Model::e_type, TypeName());
76 setProperty(Model::e_name,
_t(
"Address"));
77 setProperty(Model::e_icon,
"pin");
80 String address()
const
82 return getProperty<String>(DesignObject::e_untranslated_string_data);
84 void setAddress(
const String& address)
86 lib_assert(address.count(
'\t') == 3,
"Bad Address");
87 if (address.count(
'\t') == 3)
88 updateProperty(DesignObject::e_untranslated_string_data, address);
90 String streetAddress()
const
92 return getProperty<String>(DesignObject::e_untranslated_string_data).splitString(
'\t')[0];
94 void setStreetAddress(
const String& street)
96 String current_data = getProperty<String>(DesignObject::e_untranslated_string_data);
97 Buffer<String> parts = current_data.splitString(
'\t');
100 for (uint04 i = 0; i < parts.size(); i++)
103 current_data += street;
105 current_data += parts[i];
107 current_data +=
"\t";
109 setAddress(current_data);
113 String s = getProperty<String>(DesignObject::e_untranslated_string_data);
114 if (s.contains(
'\t'))
115 return s.splitString(
'\t')[1];
119 void setCity(
const String& city)
121 String current_data = getProperty<String>(DesignObject::e_untranslated_string_data);
122 Buffer<String> parts = current_data.splitString(
'\t');
124 current_data.clear();
125 for (uint04 i = 0; i < parts.size(); i++)
128 current_data += city;
130 current_data += parts[i];
132 current_data +=
"\t";
134 setAddress(current_data);
139 String s = getProperty<String>(DesignObject::e_untranslated_string_data);
140 if (s.count(
'\t') >= 2)
141 return s.splitString(
'\t')[2];
145 void setState(
const String& state)
147 String current_data = getProperty<String>(DesignObject::e_untranslated_string_data);
148 Buffer<String> parts = current_data.splitString(
'\t');
150 current_data.clear();
151 for (uint04 i = 0; i < parts.size(); i++)
154 current_data += state;
156 current_data += parts[i];
158 current_data +=
"\t";
160 setAddress(current_data);
163 String zipCode()
const
165 String s = getProperty<String>(DesignObject::e_untranslated_string_data);
166 if (s.count(
'\t') >= 3)
167 return s.splitString(
'\t')[3];
171 void setZipCode(
const String& zip)
173 String current_data = getProperty<String>(DesignObject::e_untranslated_string_data);
174 Buffer<String> parts = current_data.splitString(
'\t');
176 current_data.clear();
177 for (uint04 i = 0; i < parts.size(); i++)
182 current_data += parts[i];
184 current_data +=
"\t";
186 setAddress(current_data);
188 static constexpr const char* TypeName() {
return "physical_address"; }
190 class EmailAddress :
public Model
193 EmailAddress(
const Model& model)
196 if (!isOfType(TypeName()))
199 setModelProperty(Model::e_type, TypeName());
202 static constexpr const char* TypeName() {
return "email_address"; }
203 void set(
const String& email)
205 setProperty(DesignObject::e_untranslated_string_data, email);
209 return getProperty<String>(DesignObject::e_untranslated_string_data);
212 class CompanyName :
public Model
215 CompanyName(
const Model& model)
218 if (!isOfType(TypeName()))
221 setModelProperty(Model::e_type, TypeName());
224 void set(
const String& companyName)
226 setProperty(DesignObject::e_untranslated_string_data, companyName);
230 return getProperty<String>(DesignObject::e_untranslated_string_data);
232 static constexpr const char* TypeName() {
return "company_name"; }
234 class CompanyRole :
public Model
237 CompanyRole(
const Model& model)
240 if (!isOfType(TypeName()))
243 setModelProperty(Model::e_type, TypeName());
246 void set(
const String& role)
248 setProperty(DesignObject::e_untranslated_string_data, role);
252 return getProperty<String>(DesignObject::e_untranslated_string_data);
254 static constexpr const char* TypeName() {
return "company_role"; }
257 class ContactInfo :
public Model
260 ContactInfo(
const Model& model)
263 if (!isOfType(TypeName()))
267 setModelProperty(Model::e_type, TypeName());
268 setProperty(DesignObject::e_name,
_t(
"Contact"));
271 ContactName contactName()
273 return ContactName(getChild(0));
275 TelephoneNumber telephoneNumber()
277 return TelephoneNumber(getChild(1));
279 EmailAddress emailAddress()
281 return EmailAddress(getChild(2));
283 CompanyName companyName()
285 return CompanyName(getChild(3));
287 CompanyRole companyRole()
289 return CompanyRole(getChild(4));
291 static constexpr const char* TypeName() {
return "contact_info"; }
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
#define _t(english_string)
Definition Translator.h:87