acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
_impl_atom.h
1//
2// Created by camilo on 23/12/2022 <3ThomasBorregaardSorensen!!!
3//
4#pragma once
5
6
7//#include "acme/constant/id.h"
8#include "acme/constant/message.h"
9#include "acme/constant/user_message.h"
10
11
12template < typename ITERATOR_TYPE >
13inline const_string_range < ITERATOR_TYPE >::const_string_range(const block & block)
14{
15
16 *this = block;
17
18}
19
20
21template < typename ITERATOR_TYPE >
22inline const_string_range < ITERATOR_TYPE > & const_string_range < ITERATOR_TYPE >::operator = (const block & block)
23{
24
25 if (block.size() % sizeof(decltype(*block.m_begin)) != 0)
26 {
27
28 throw ::exception(error_failed, "data type misalignment");
29
30 }
31
32 this->m_begin = (ITERATOR_TYPE)block.m_begin;
33 this->m_end = (ITERATOR_TYPE)block.m_end;
34
35 return *this;
36
37}
38
39
40//template < typename ITERATOR_TYPE >
41//inline const_string_range < ITERATOR_TYPE >::const_string_range(const block & block)
42//{
43//
44//
45// throw_exception(error_not_supported);
46//
47//
48//}
49
50
51
52//template < >
53//inline string_range < const_char_pointer >::string_range(const atom & atom)
54//{
55//
56// if (atom.is_text())
57// {
58//
59// this->m_begin = atom.m_str.m_begin;
60// this->m_end = atom.m_str.m_end;
61//
62// }
63// else
64// {
65//
66// this->m_begin = nullptr;
67// this->m_end = nullptr;
68//
69// }
70//
71//}
72
73
74template < typename ITERATOR_TYPE >
75template < prototype_block BLOCK >
76inline string_range < ITERATOR_TYPE >::string_range(const BLOCK & block) :
77 const_string_range < ITERATOR_TYPE >(block)
78{
79
80 //this->m_begin = (ITERATOR_TYPE)block.m_begin;
81 //this->m_end = (ITERATOR_TYPE)block.m_end;
82
83}
84
85
86//template < >
87//inline string_range < const_char_pointer >& string_range < const_char_pointer >::operator = (const atom & atom)
88//{
89//
90// if (atom.is_text())
91// {
92//
93// BASE_RANGE::operator=(atom.m_str);
94//
95// }
96// else
97// {
98//
99// this->m_begin = nullptr;
100// this->m_end = nullptr;
101//
102// }
103//
104// return *this;
105//
106//}
107
108
109//template < >
110//inline string_range < const_char_pointer >& string_range < const_char_pointer >::operator = (const block & block)
111//{
112//
113//
114// this->m_begin = (const_char_pointer )block.m_begin;
115// this->m_end = (const_char_pointer )block.m_end;
116//
117// return *this;
118//
119//}
120
121
122//template < typename ITERATOR_TYPE >
123//inline string_range < ITERATOR_TYPE >::string_range(const atom & atom)
124//{
125//
126//
127// throw_exception(error_not_supported);
128//
129//
130//}
131
132
133//template < typename ITERATOR_TYPE >
134//inline string_range < ITERATOR_TYPE >::string_range(const block & block)
135//{
136//
137//
138// throw_exception(error_not_supported);
139//
140//
141//}
142
143
144//template < typename ITERATOR_TYPE >
145//inline mutable_string_range < ITERATOR_TYPE >::mutable_string_range(const atom & atom)
146//{
147//
148//
149// throw_exception(error_not_supported);
150//
151//
152//}
153
154
155template < typename ITERATOR_TYPE >
156inline mutable_string_range < ITERATOR_TYPE >::mutable_string_range(const block & block) :
157 string_range < ITERATOR_TYPE >(block)
158{
159
160
161 //throw_exception(error_not_supported);
162
163
164}
165
166
167//template < typename ITERATOR_TYPE >
168//inline string_range < ITERATOR_TYPE > & string_range < ITERATOR_TYPE >::operator = (const atom & atom)
169//{
170//
171// throw_exception(error_not_supported);
172//
173//
174//}
175
176
177//template < typename ITERATOR_TYPE >
178//inline string_base < ITERATOR_TYPE > & string_base < ITERATOR_TYPE >::operator = (const ::atom & atom)
179//{
180//
181// assign_range(atom.as_string());
182//
183// return *this;
184//
185//}
186
187
188//template < typename ITERATOR_TYPE >
189//string_base < ITERATOR_TYPE > & string_base < ITERATOR_TYPE >::operator += (const ::atom & atom)
190//{
191//
192// return operator +=(atom.operator ::string());
193//
194//}
195
196
197//template < typename ITERATOR_TYPE >
198//inline scoped_string_base < ITERATOR_TYPE >::scoped_string_base(const ::atom & atom) :
199// m_str(no_initialize_t{}), RANGE(no_initialize_t{})
200//{
201//
202// m_str = atom.as_string();
203//
204// RANGE::operator = (m_str);
205//
206//}
207
208
209//template < >
210//inline scoped_string_base < const_char_pointer >::scoped_string_base(const ::atom & atom) :
211// m_str(no_initialize_t{}), RANGE(no_initialize_t{})
212//{
213//
214// if (atom.is_text())
215// {
216//
217// RANGE::operator=(atom.m_str);
218//
219// }
220// else
221// {
222//
223// this->m_begin = nullptr;
224// this->m_end = nullptr;
225//
226// }
227//
228//}
229
230
231// template < typename ITERATOR_TYPE >
232// inline string_range < ITERATOR_TYPE > & string_range < ITERATOR_TYPE >::operator = (const block & block)
233// {
234//
235// this->m_begin = (const CHARACTER *)block.data();
236// this->m_end = (const CHARACTER *)block.end();
237//
238// return *this;
239//
240// }
241
242
243inline atom::atom()
244{
245
246 m_etype = e_type_null;
247
248 m_uLargest = 0;
249
250}
251
252
253inline atom::atom(enum_type etype)
254{
255
256 m_etype = etype;
257
258 m_uLargest = 0;
259
260}
261
262
263inline atom::atom(enum_id eid) :
264 m_etype(e_type_id),
265 m_iLargest((::iptr) eid) // used m_iLargest to reset 64-bit field
266{
267
268}
269
270
271inline atom::atom(enum_element eelement) :
272 m_etype(e_type_element),
273 m_iLargest((::iptr)eelement) // used m_iLargest to reset 64-bit field
274{
275
276}
277
278
279//inline atom::atom(const ::e_command & ecommand) :
280// m_etype(e_type_command),
281// m_iLargest((::iptr) ecommand) // used m_iLargest to reset 64-bit field
282//{
283//
284//}
285
286
287// inline atom::atom(::enum_id EID) :
288// atom((::enum_id)EID) // used m_iLargest to reset 64-bit field
289// {
290//
291// }
292
293
294inline atom::atom(::user::enum_message eusermessage) :
295 m_etype(e_type_user_message),
296 m_iLargest((::iptr)eusermessage) // used m_iLargest to reset 64-bit field
297{
298
299}
300inline atom::atom(::enum_message emessage) :
301 m_etype(e_type_message), m_iLargest((::iptr)emessage) // used m_iLargest to reset 64-bit field
302{
303}
304
305
306// inline atom::atom(ENUM_MESSAGE EMESSAGE) :
307// atom((::user::enum_message)EMESSAGE)
308// {
309//
310// }
311
312
313inline atom::atom(enum_impact eimpact) :
314 m_etype(e_type_impact),
315 m_iLargest((::iptr)eimpact) // used m_iLargest to reset 64-bit field
316{
317
318}
319
320
321inline atom::atom(ENUM_IMPACT EIMPACT) :
322 atom((::enum_impact) EIMPACT)
323{
324
325}
326
327
328inline atom::atom(enum_property eproperty) :
329 m_etype(e_type_property),
330 m_iLargest((::iptr)eproperty) // used m_iLargest to reset 64-bit field
331{
332
333}
334
335
336inline atom::atom(enum_factory efactory) :
337 m_etype(e_type_factory),
338 m_iLargest((::i64)efactory) // used m_iLargest to reset 64-bit field
339{
340
341}
342
343
344inline atom::atom(enum_task_tool etasktool) :
345 m_etype(e_type_task_tool),
346 m_iLargest((::iptr)etasktool) // used m_iLargest to reset 64-bit field
347{
348
349}
350
351
352inline atom::atom(enum_timer etimer) :
353 m_etype(e_type_timer),
354 m_iLargest((::iptr)etimer) // used m_iLargest to reset 64-bit field
355{
356
357}
358
359
360//inline atom::atom(enum_topic etopic) :
361// m_etype(e_type_subject),
362// m_etopic(etopic)
363//{
364//
365//}
366
367
368inline atom::atom(enum_dialog_result edialogresult) :
369 m_etype(e_type_dialog_result),
370 m_iLargest((::iptr)edialogresult) // used m_iLargest to reset 64-bit field
371{
372
373}
374
375
376inline atom::atom(enum_happening ehappening) :
377 m_etype(e_type_happening),
378 m_iLargest((::iptr)ehappening) // used m_iLargest to reset 64-bit field
379{
380
381}
382
383
384inline atom::atom(enum_check echeck) :
385 m_etype(e_type_check),
386 m_iLargest((::iptr)echeck) // used m_iLargest to reset 64-bit field
387{
388
389}
390
391
392inline atom::atom(enum_status estatus) :
393 m_etype(e_type_status),
394 m_iLargest((::iptr)estatus) // used m_iLargest to reset 64-bit field
395{
396
397}
398
399
400// This constructor shouldn't change the prototype type of
401// the atom argument.
402inline atom::atom(enum_type etypeAdd, const ::atom & atom)
403{
404
405 if (atom.is_text())
406 {
407
408 m_etype = (enum_type) (etypeAdd | e_type_text);
409
410 m_str.construct_from_string(atom.m_str);
411
412 }
413 else if (atom.is_integer())
414 {
415
416 m_etype = etypeAdd;
417
418 m_iLargest = atom.m_iLargest;
419
420 }
421 else
422 {
423
424 m_etype = etypeAdd;
425
426 m_iLargest = 0;
427
428 }
429
430}
431
432
433inline atom::atom(::atom && atom)
434{
435 m_etype = atom.m_etype;
436 if (atom.m_etype >= 0)
437 {
438 if (atom.m_etype & e_type_text)
439 {
440 m_str.construct_from_string(::transfer(atom.m_str));
441 }
442 else
443 {
444 m_uLargest = atom.m_uLargest;
445 }
446 }
447 atom.m_etype = e_type_integer;
448 atom.m_uLargest = 0;
449}
450
451
452inline atom::atom(const atom & atom)
453{
454
455 if (atom.is_text())
456 {
457
458 m_etype = atom.m_etype;
459
460 m_str.construct_from_string(atom.m_str);
461
462 }
463 else
464 {
465
466 m_uLargest = atom.m_uLargest;
467 m_etype = atom.m_etype;
468
469 }
470
471}
472
473
474inline atom::atom(const domain_id & domainid) :
475 m_etype(e_type_domainid),
476 m_iLargest(0)
477{
478
479 m_domainid = domainid;
480
481}
482
483inline atom::atom(const_char_pointer psz) :
484 m_str(psz)
485{
486
487 m_etype = e_type_text;
488
489}
490
491
492inline atom::atom(const ::scoped_string & scopedstr) :
493 m_str(scopedstr)
494{
495
496 m_etype = e_type_text;
497
498}
499
500
501inline atom::atom(const ::inline_number_string & inline_number_string) :
502 m_str(inline_number_string)
503{
504
505 m_etype = e_type_text;
506
507}
508
509
510inline atom::atom(const ::platform::type & type) :
511 m_str(type.name())
512{
513
514 m_etype = e_type_text;
515
516}
517
518
519template < prototype_signed SIGNED >
520inline atom::atom(SIGNED i)
521{
522
523 m_etype = e_type_integer;
524
525 m_iLargest = (::iptr) i;
526
527}
528
529
530template < prototype_unsigned UNSIGNED >
531inline atom::atom(UNSIGNED u)
532{
533
534 m_etype = e_type_integer;
535
536 m_uLargest = u;
537
538}
539
540
541template < prototype_raw_enum ENUM >
542inline atom::atom(ENUM e)
543{
544
545 m_etype = e_type_integer;
546
547 m_iLargest = ::as_i64(e);
548
549}
550
551
552template<prototype_enumeration ENUMERATION>
553inline atom::atom(const ENUMERATION & e) :
554 atom(e.m_eenum)
555{
556
557
558}
559
560
561
562inline bool atom::operator == (const atom & atom) const
563{
564
565 if (m_etype != atom.m_etype)
566 {
567
568 return false;
569
570 }
571
572 if (is_text())
573 {
574
575 return m_str == atom.m_str;
576
577 }
578 else
579 {
580
581 return m_iLargest == atom.m_iLargest;
582
583 }
584
585}
586
587
588inline ::std::strong_ordering atom::operator <=>(const atom & atom) const
589{
590
591 auto compare = m_etype <=> atom.m_etype;
592
593 if (compare != 0)
594 {
595
596 return compare;
597
598 }
599
600 if (is_text())
601 {
602
603 return m_str <=> atom.m_str;
604
605 }
606 else
607 {
608
609 return m_iLargest <=> atom.m_iLargest;
610
611 }
612
613}
614
615
616//inline bool atom::operator != (const atom & atom) const
617//{
618//
619// return order(atom) != 0;
620//
621//}
622//
623//
624//inline bool atom::operator < (const atom & atom) const
625//{
626//
627// return order(atom) < 0;
628//
629//}
630//
631//
632//inline bool atom::operator >(const atom & atom) const
633//{
634//
635// return order(atom) > 0;
636//
637//}
638//
639//
640//inline bool atom::operator <= (const atom & atom) const
641//{
642//
643// return order(atom) <= 0;
644//
645//}
646//
647//
648//inline bool atom::operator >= (const atom & atom) const
649//{
650//
651// return order(atom) >= 0;
652//
653//}
654//
655
656inline atom & atom::operator = (const atom & atom)
657{
658
659 if (is_text() && !is_range())
660 {
661
662 if(atom.is_text() && !atom.is_range())
663 {
664
665 m_str = atom.m_str;
666
667 }
668 else
669 {
670
671 _defer_free();
672
673 if (atom.is_range())
674 {
675
676 m_range = atom.m_range;
677
678 }
679 else
680 {
681
682 m_uLargest = atom.m_uLargest;
683
684 }
685
686 }
687
688 }
689 else
690 {
691
692 if (atom.is_range())
693 {
694
695 m_range = atom.m_range;
696
697 }
698 else if (atom.is_text())
699 {
700
701 m_str.construct_from_string(atom.m_str);
702
703 }
704 else
705 {
706
707 m_uLargest = atom.m_uLargest;
708
709 }
710
711 }
712
713 m_etype = atom.m_etype;
714
715 return *this;
716
717}
718
719
720template < prototype_character_range RANGE >
721inline bool atom::operator == (const RANGE & range) const
722{
723
724 return is_text() ? m_str == range : false;
725
726}
727
728
729//inline ::std::strong_ordering atom::operator <=>(const ::scoped_string & scopedstr) const
730//{
731//
732// return is_text() ? m_str <=> str : m_etype <=> e_type_text;
733//
734//}
735
736
737
738//inline ::std::strong_ordering atom::operator <=> (const ::scoped_string & scopedstr) const
739//{
740//
741// return order(str);
742//
743//}
744//
745//
746//inline bool atom::operator < (const ::scoped_string & scopedstr) const
747//{
748//
749// return order(str) < 0;
750//
751//}
752//
753//
754//inline bool atom::operator <= (const ::scoped_string & scopedstr) const
755//{
756//
757// return order(str) <= 0;
758//
759//}
760//
761//
762//inline bool atom::operator > (const ::scoped_string & scopedstr) const
763//{
764//
765// return order(str) > 0;
766//
767//}
768//
769//
770//inline bool atom::operator >= (const ::scoped_string & scopedstr) const
771//{
772//
773// return order(str) >= 0;
774//
775//}
776
777
778//inline void atom::as(::string & str) const
779//{
780//
781// str = this->string();
782//
783//}
784
785
786//#endif
787
788
789//inline atom::operator const_char_pointer () const
790//{
791//
792// return is_text() ? m_str.c_str() : nullptr;
793//
794//}
795//
796
797
798//inline string atom::as_string() const
799//{
800//
801// return str();
802//
803//}
804
805
806inline bool atom::is_empty() const
807{
808
809 return is_null() || m_etype == e_type_empty || (is_text() && m_str.is_empty());
810
811}
812
813//
814//inline CLASS_DECL_ACME::std::strong_ordering atom_order(const atom * pid1,const atom * pid2)
815//{
816//
817// return pid1->m_str.order(pid2->m_str);
818//
819//}
820
821template < character_pointer CHARACTER_POINTER >
822inline bool atom::operator == (CHARACTER_POINTER p) const
823{
824
825 return is_text() ? m_str == p : false;
826
827}
828
829
830template < prototype_character_range RANGE >
831inline ::std::strong_ordering atom::operator<=>(const RANGE & range) const
832{
833
834 return is_text() ? m_str <=> range : m_etype <=> e_type_text;
835
836}
837
838
839
840
841//inline bool atom::operator != (const ::scoped_string & scopedstr) const
842//{
843//
844// return order(scopedstr) != 0;
845//
846//
847//}
848//
849//inline bool atom::operator < (const ::scoped_string & scopedstr) const
850//{
851//
852// return order(scopedstr) < 0;
853//
854//}
855//
856//
857//inline bool atom::operator > (const ::scoped_string & scopedstr) const
858//{
859//
860// return order(scopedstr) > 0;
861//
862//}
863//
864//
865//
866//inline bool atom::operator <= (const ::scoped_string & scopedstr) const
867//{
868//
869// return order(scopedstr) <= 0;
870//
871//}
872//
873//
874//inline bool atom::operator >= (const ::scoped_string & scopedstr) const
875//{
876//
877// return order(scopedstr) >= 0;
878//
879//}
880
881
882template < prototype_integral INTEGRAL >
883inline bool atom::operator == (INTEGRAL i) const
884{
885
886return ::comparison::tuple
887(
888[&]() { return m_etype == e_type_integer; },
889[&]() { return m_iLargest == i; }
890);
891
892}
893
894
895template < prototype_integral INTEGRAL >
896inline ::std::strong_ordering atom::operator <=>(INTEGRAL i) const
897{
898
899return ::comparison::tuple
900(
901[&]() { return m_etype <=> e_type_integer; },
902[&]() { return m_iLargest <=> i; }
903);
904
905}
906
907
908//template < prototype_integral INTEGRAL >
909//inline bool atom::operator != (INTEGRAL i) const
910//{
911//
912// return order(i) != 0;
913//
914//}
915//
916//
917//template < prototype_integral INTEGRAL >
918//inline bool atom::operator < (INTEGRAL i) const
919//{
920//
921// return order(i) < 0;
922//
923//}
924//
925//
926//template < prototype_integral INTEGRAL >
927//inline bool atom::operator <= (INTEGRAL i) const
928//{
929//
930// return order(i) <= 0;
931//
932//}
933//
934//
935//template < prototype_integral INTEGRAL >
936//inline bool atom::operator > (INTEGRAL i) const
937//{
938//
939// return order(i) > 0;
940//
941//}
942//
943//
944//template < prototype_integral INTEGRAL >
945//inline bool atom::operator >= (INTEGRAL i) const
946//{
947//
948// return order(i) >= 0;
949//
950//}
951
952
953//#endif
954
955
956inline bool atom::operator == (::enum_id eid) const
957{
958
959 return ::comparison::tuple
960 (
961 [&]() { return m_etype == e_type_id; },
962 [&]() { return m_eid == eid; }
963 );
964
965}
966
967
968inline ::std::strong_ordering atom::operator <=>(::enum_id eid) const
969{
970
971 return ::comparison::tuple
972 (
973 [&]() { return m_etype <=> e_type_id; },
974 [&]() { return m_eid <=> eid; }
975 );
976
977}
978
979
980inline bool atom::operator == (::enum_command ecommand) const
981{
982
983 return ::comparison::tuple
984 (
985 [&]() { return m_etype == e_type_command; },
986 [&]() { return m_ecommand == ecommand; }
987 );
988
989}
990
991
992inline ::std::strong_ordering atom::operator <=>(::enum_command ecommand) const
993{
994
995 return ::comparison::tuple
996 (
997 [&]() { return m_etype <=> e_type_command; },
998 [&]() { return m_ecommand <=> ecommand; }
999 );
1000
1001}
1002
1003
1004inline bool atom::operator == (::enum_impact eimpact) const
1005{
1006
1007 return ::comparison::tuple
1008 (
1009 [&]() { return m_etype == e_type_impact; },
1010 [&]() { return m_eimpact == eimpact; }
1011 );
1012
1013}
1014
1015
1016inline ::std::strong_ordering atom::operator <=>(::enum_impact eimpact) const
1017{
1018
1019 return ::comparison::tuple
1020 (
1021 [&]() { return m_etype <=> e_type_impact; },
1022 [&]() { return m_eimpact <=> eimpact; }
1023 );
1024
1025}
1026
1027
1028
1029inline bool atom::operator == (const ::domain_id & domainid) const
1030{
1031
1032 return ::comparison::tuple
1033 (
1034 [&]() { return m_etype == e_type_domainid; },
1035 [&]() { return m_domainid == domainid; }
1036 );
1037
1038}
1039
1040
1041inline ::std::strong_ordering atom::operator <=>(const ::domain_id & domainid) const
1042{
1043
1044 return ::comparison::tuple
1045 (
1046 [&]() { return m_etype <=> e_type_domainid; },
1047 [&]() { return m_domainid <=> domainid; }
1048 );
1049
1050}
1051
1052//inline bool atom::operator != (::enum_id eid) const
1053//{
1054//
1055// return order(eid) != 0;
1056//
1057//}
1058//
1059//
1060//inline bool atom::operator < (::enum_id eid) const
1061//{
1062//
1063// return order(eid) < 0;
1064//
1065//}
1066//
1067//
1068//inline bool atom::operator <= (::enum_id eid) const
1069//{
1070//
1071// return order(eid) <= 0;
1072//
1073//}
1074//
1075//
1076//inline bool atom::operator > (::enum_id eid) const
1077//{
1078//
1079// return order(eid) > 0;
1080//
1081//}
1082//
1083//
1084//inline bool atom::operator >= (::enum_id eid) const
1085//{
1086//
1087// return order(eid) >= 0;
1088//
1089//}
1090//
1091
1092
1093inline bool atom::operator == (::user::enum_message eusermessage) const
1094{
1095
1096 return ::comparison::tuple
1097 (
1098 [&]() { return m_etype == e_type_message; },
1099 [&]() { return m_eusermessage == eusermessage; }
1100 );
1101
1102}
1103
1104
1105
1106inline ::std::strong_ordering atom::operator <=>(::user::enum_message eusermessage) const
1107{
1108
1109 return ::comparison::tuple
1110 (
1111 [&]() { return m_etype <=> e_type_message; },
1112 [&]() { return m_eusermessage <=> eusermessage; }
1113 );
1114
1115}
1116
1117
1118
1119
1120inline bool atom::operator==(::enum_message emessage) const
1121{
1122
1123 return ::comparison::tuple([&]() { return m_etype == e_type_message; },
1124 [&]() { return m_emessage == emessage; });
1125}
1126
1127
1128inline ::std::strong_ordering atom::operator<=>(::enum_message emessage) const
1129{
1130
1131 return ::comparison::tuple([&]() { return m_etype <=> e_type_message; },
1132 [&]() { return m_emessage <=> emessage; });
1133}
1134
1135
1136//inline bool atom::operator != (::user::enum_message eusermessage) const
1137//{
1138//
1139// return order(emessage) != 0;
1140//
1141//}
1142//
1143//
1144//inline bool atom::operator < (::user::enum_message eusermessage) const
1145//{
1146//
1147// return order(emessage) < 0;
1148//
1149//}
1150//
1151//
1152//inline bool atom::operator <= (::user::enum_message eusermessage) const
1153//{
1154//
1155// return order(emessage) <= 0;
1156//
1157//}
1158//
1159//
1160//inline bool atom::operator > (::user::enum_message eusermessage) const
1161//{
1162//
1163// return order(emessage) > 0;
1164//
1165//}
1166//
1167//
1168//inline bool atom::operator >= (::user::enum_message eusermessage) const
1169//{
1170//
1171// return order(emessage) >= 0;
1172//
1173//}
1174//
1175
1176//inline ::i32 atom::order(::enum_topic etopic) const
1177//{
1178//
1179// return __atom_compare_square(m_etype - e_type_subject, m_etopic - etopic);
1180//
1181//}
1182//
1183//
1184//inline bool atom::operator == (::enum_topic etopic) const
1185//{
1186//
1187// return order(etopic) == 0;
1188//
1189//}
1190//
1191//
1192//inline bool atom::operator != (::enum_topic etopic) const
1193//{
1194//
1195// return order(etopic) != 0;
1196//
1197//}
1198//
1199//
1200//inline bool atom::operator < (::enum_topic etopic) const
1201//{
1202//
1203// return order(etopic) < 0;
1204//
1205//}
1206//
1207//
1208//inline bool atom::operator <= (::enum_topic etopic) const
1209//{
1210//
1211// return order(etopic) <= 0;
1212//
1213//}
1214//
1215//
1216//inline bool atom::operator > (::enum_topic etopic) const
1217//{
1218//
1219// return order(etopic) > 0;
1220//
1221//}
1222//
1223//
1224//inline bool atom::operator >= (::enum_topic etopic) const
1225//{
1226//
1227// return order(etopic) >= 0;
1228//
1229//}
1230
1231
1232inline bool atom::operator == (::enum_dialog_result edialogresult) const
1233{
1234
1235 return ::comparison::tuple
1236 (
1237 [&]() { return m_etype == e_type_dialog_result; },
1238 [&]() { return m_edialogresult == edialogresult; }
1239 );
1240
1241}
1242
1243
1244inline ::std::strong_ordering atom::operator <=>(::enum_dialog_result edialogresult) const
1245{
1246
1247 return ::comparison::tuple
1248 (
1249 [&]() { return m_etype <=> e_type_dialog_result; },
1250 [&]() { return m_edialogresult <=> edialogresult; }
1251 );
1252
1253}
1254
1255
1256//inline bool atom::operator != (::enum_dialog_result edialogresult) const
1257//{
1258//
1259// return order(edialogresult) != 0;
1260//
1261//}
1262//
1263//
1264//inline bool atom::operator < (::enum_dialog_result edialogresult) const
1265//{
1266//
1267// return order(edialogresult) < 0;
1268//
1269//}
1270//
1271//
1272//inline bool atom::operator <= (::enum_dialog_result edialogresult) const
1273//{
1274//
1275// return order(edialogresult) <= 0;
1276//
1277//}
1278//
1279//
1280//inline bool atom::operator > (::enum_dialog_result edialogresult) const
1281//{
1282//
1283// return order(edialogresult) > 0;
1284//
1285//}
1286//
1287//
1288//inline bool atom::operator >= (::enum_dialog_result edialogresult) const
1289//{
1290//
1291// return order(edialogresult) >= 0;
1292//
1293//}
1294
1295
1296
1297inline bool atom::operator == (::enum_happening ehappening) const
1298{
1299
1300 return ::comparison::tuple
1301 (
1302 [&]() { return m_etype == e_type_happening; },
1303 [&]() { return m_ehappening == ehappening; }
1304 );
1305
1306}
1307
1308
1309inline ::std::strong_ordering atom::operator <=>(::enum_happening ehappening) const
1310{
1311
1312 return ::comparison::tuple
1313 (
1314 [&]() { return m_etype <=> e_type_happening; },
1315 [&]() { return m_ehappening <=> ehappening; }
1316 );
1317
1318}
1319
1320
1321//inline bool atom::operator != (::enum_happening eid) const
1322//{
1323//
1324// return order(eid) != 0;
1325//
1326//}
1327//
1328//
1329//inline bool atom::operator < (::enum_happening eid) const
1330//{
1331//
1332// return order(eid) < 0;
1333//
1334//}
1335//
1336//
1337//inline bool atom::operator <= (::enum_happening eid) const
1338//{
1339//
1340// return order(eid) <= 0;
1341//
1342//}
1343//
1344//
1345//inline bool atom::operator > (::enum_happening eid) const
1346//{
1347//
1348// return order(eid) > 0;
1349//
1350//}
1351//
1352//
1353//inline bool atom::operator >= (::enum_happening eid) const
1354//{
1355//
1356// return order(eid) >= 0;
1357//
1358//}
1359//
1360
1361//inline atom::operator ::iptr () const
1362//{
1363//
1364// return as_iptr();
1365//
1366//}
1367
1368
1369inline ::i64 atom::as_i64() const
1370{
1371
1372 return prototype_type() == e_type_integer ? m_iLargest : 0x8000000000000000ll;
1373
1374}
1375
1376
1377inline ::iptr atom::as_iptr() const
1378{
1379
1380 return prototype_type() == e_type_integer ? m_iLargest : INTPTR_MIN;
1381
1382}
1383
1384
1385inline ::user::enum_message atom::as_eusermessage() const
1386{
1387
1388 return m_etype == e_type_user_message ? m_eusermessage : (::user::enum_message) ::user::e_message_undefined;
1389
1390}
1391
1392
1393inline ::enum_message atom::as_emessage1() const
1394{
1395
1396 return m_etype == e_type_message ? m_emessage : (::enum_message)::e_message_undefined;
1397}
1398
1399
1400inline enum_id atom::as_eid() const
1401{
1402
1403 return m_etype == e_type_id ? m_eid : (enum_id)0;
1404
1405}
1406
1407
1408//inline e_check atom::as_echeck() const
1409//{
1410//
1411// return m_etype == e_type_check ? m_echeck : (enum_check) e_check_undefined;
1412//
1413//}
1414
1415
1416//inline atom::operator enum_dialog_result () const
1417//{
1418//
1419// return m_etype == e_type_dialog_result ? m_edialogresult : e_dialog_result_none;
1420//
1421//}
1422
1423
1424inline bool atom::is_null() const
1425{
1426
1427 return m_etype == e_type_null || (is_text() && m_str.is_empty());
1428
1429}
1430
1431
1432inline bool atom::has_character() const
1433{
1434
1435 return is_text() && m_str.has_character();
1436
1437}
1438
1439
1440inline void atom::Empty()
1441{
1442
1443 m_etype = e_type_empty;
1444
1445 m_iLargest = 0;
1446
1447}
1448
1449
1450inline void atom::clear()
1451{
1452
1453 m_etype = e_type_null;
1454
1455}
1456
1457
1458//inline CLASS_DECL_ACME atom & atom::operator += (const ::scoped_string & scopedstr) { return operator = (string(*this) + string(scopedstr)); }
1459
1460
1461inline ::std::strong_ordering atom::case_insensitive_order(const ::scoped_string & scopedstr) const
1462{
1463
1464 if(is_empty())
1465 {
1466
1467 if (scopedstr.is_empty())
1468 {
1469
1470 return ::std::strong_ordering::equal;
1471
1472 }
1473 else
1474 {
1475
1476 return ::std::strong_ordering::less;
1477
1478 }
1479
1480 }
1481 else if(scopedstr.is_empty())
1482 {
1483
1484 return ::std::strong_ordering::greater;
1485
1486 }
1487 else
1488 {
1489
1490 return m_str.case_insensitive_order(scopedstr);
1491
1492 }
1493
1494}
1495
1496
1497template < >
1498inline bool EqualElements< atom >(atom element1, atom element2)
1499{
1500
1501 return element1 == element2;
1502
1503}
1504
1505
1506
1507//inline string CLASS_DECL_ACME operator + (const ::scoped_string & scopedstr, const ::atom & atom);
1508
1509//
1510//namespace acme
1511//{
1512//
1513// CLASS_DECL_ACME ::atom atom(const ::scoped_string & scopedstr);
1514//
1515//}
1516//
1517//
1518//class CLASS_DECL_ACME __atom :
1519//public atom
1520//{
1521//
1522//public:
1523//
1524// using atom::atom;
1525//
1526//};
1527
1528
1529inline bool atom::begins(const ::scoped_string & scopedstrCandidatePrefix) const
1530{
1531
1532 if (scopedstrCandidatePrefix.is_empty())
1533 {
1534
1535 return true;
1536
1537 }
1538
1539 if (is_empty() || is_integer())
1540 {
1541
1542 return false;
1543
1544 }
1545 else if (is_text())
1546 {
1547
1548 return m_str.begins(scopedstrCandidatePrefix);
1549
1550 }
1551 else
1552 {
1553
1554 throw "Unexpected::atom m_etype";
1555
1556 return false;
1557
1558 }
1559
1560}
1561
1562
1563inline bool atom::case_insensitive_begins(const ::scoped_string & scopedstrCandidatePrefix) const
1564{
1565
1566 if (scopedstrCandidatePrefix.is_empty())
1567 {
1568
1569 return true;
1570
1571 }
1572
1573 if (is_empty())
1574 {
1575
1576 return false;
1577
1578 }
1579 else if (is_text())
1580 {
1581
1582 return m_str.case_insensitive_begins(scopedstrCandidatePrefix);
1583
1584 }
1585 else
1586 {
1587
1588 //throw "Unexpected ::atom m_etype";
1589
1590 return false;
1591
1592 }
1593
1594}
1595
1596
1597inline bool atom::ends(const ::scoped_string & scopedstrCandidateSuffix) const
1598{
1599
1600 if (scopedstrCandidateSuffix.is_empty())
1601 {
1602
1603 return true;
1604
1605 }
1606
1607 if (is_empty() || is_integer())
1608 {
1609
1610 return false;
1611
1612 }
1613 else if (is_text())
1614 {
1615
1616 return m_str.ends(scopedstrCandidateSuffix);
1617
1618 }
1619 else
1620 {
1621
1622 throw "Unexpected::atom m_etype";
1623
1624 return false;
1625
1626 }
1627
1628}
1629
1630
1631inline bool atom::case_insensitive_ends(const ::scoped_string & scopedstrCandidateSuffix) const
1632{
1633
1634 if (scopedstrCandidateSuffix.is_empty())
1635 {
1636
1637 return true;
1638
1639 }
1640
1641 if (is_empty())
1642 {
1643
1644 return false;
1645
1646 }
1647 else if (is_text())
1648 {
1649
1650 return m_str.case_insensitive_ends(scopedstrCandidateSuffix);
1651
1652 }
1653 else
1654 {
1655
1656 throw "Unexpected ::atom m_etype";
1657
1658 return false;
1659
1660 }
1661
1662}
1663
1664
1665
1666
1667
1668
1669inline void from_string(::atom & atom, const_char_pointer psz)
1670{
1671
1672 atom = psz;
1673
1674}
1675
1676
1677//inline atom::atom(const_char_pointer psz) :
1678// m_str(scopedstr)
1679//{
1680//
1681// m_etype = e_type_text;
1682//
1683// //m_str.::string::string(scopedstr);
1684//
1685//}
1686
1687
1688//inline atom::atom(const ::lparam & lparam)
1689//{
1690//
1691// m_etype = e_type_integer;
1692//
1693// m_uLargest = lparam.m_lparam;
1694//
1695//}
1696//
1697//
1698//inline atom::atom(const ::scoped_string & scopedstr) :
1699// m_str(str)
1700//{
1701//
1702// m_etype = e_type_text;
1703//
1704//}
1705//
1706//
1707//inline atom::atom(const const_ansi_range & range) :
1708// m_range(range)
1709//{
1710//
1711// m_etype = e_type_range;
1712//
1713//}
1714//
1715//inline atom::atom(const_ansi_range && range) :
1716// m_range(::transfer(range))
1717//{
1718//
1719// m_etype = e_type_range;
1720//
1721//}
1722//
1723//
1724//inline atom::atom(const const_ansi_range && range) :
1725// m_range(::transfer(range))
1726//{
1727//
1728// m_etype = e_type_range;
1729//
1730//}
1731//
1732//
1733//inline atom::atom(const ::inline_number_string& inlinenumberstring) :
1734// m_str(inlinenumberstring)
1735//{
1736//
1737// m_etype = e_type_text;
1738//
1739//}
1740
1741
1742//template < typename CHAR >
1743//inline string_base < CHAR >::string_base(const ::atom & atom) :
1744// string_base(atom.string())
1745//{
1746//
1747//
1748//}
1749
1750
1751// template < typename CHAR >
1752// string_base < CHAR > & string_base < CHAR >::operator +=(const ::atom & atom)
1753// {
1754//
1755// return append(atom);
1756//
1757// }
1758
1759
1760//template < typename ITERATOR_TYPE >
1761//template < ::i32 t_size >
1762//inline string_base < ITERATOR_TYPE > & string_base < ITERATOR_TYPE >::append(const const_string_range_static_array< const CHARACTER *, t_size > & a)
1763//{
1764//
1765// auto old_len = size();
1766//
1767// auto add_len = a.size();
1768//
1769// auto new_len = old_len + add_len;
1770//
1771// auto p = get_buffer<true>(new_len);
1772//
1773// a.block_concatenate_to(p);
1774//
1775// *p = {};
1776//
1777// return *this;
1778//
1779//}
1780
1781
1782//template < typename ITERATOR_TYPE >
1783//template < other_primitive_character < typename string_base < ITERATOR_TYPE >::CHARACTER > OTHER_CHARACTER, ::i32 t_size >
1784//inline string_base < ITERATOR_TYPE > & string_base < ITERATOR_TYPE >::append(const const_string_range_static_array< const OTHER_CHARACTER *, t_size >& a)
1785//{
1786//
1787// auto old_len = size();
1788//
1789// character_count iaLen[t_size];
1790//
1791// character_count* plen = iaLen;
1792//
1793// auto newLen = oldLen + a.__utf_length(this->m_begin, plen);
1794//
1795// set_size(newLen);
1796//
1797// auto p = (CHARACTER*)this->m_begin;
1798//
1799// p += oldLen;
1800//
1801// plen = iaLen;
1802//
1803// a.__utf_concatenate_to(p, plen);
1804//
1805// *p = {};
1806//
1807// return *this;
1808//
1809//}
1810
1811
1812template < typename CHAR >
1813string_base < CHAR > & string_base < CHAR >::append(const ::atom & atom)
1814{
1815
1816 if (atom.is_text())
1817 {
1818
1819 return append(atom.m_range);
1820
1821 }
1822 else
1823 {
1824
1825 return append(atom.as_string());
1826
1827 }
1828
1829}
1830
1831
1832//
1833//template < typename TYPE_CHAR >
1834//string_base < TYPE_CHAR > string_base < TYPE_CHAR >::operator +(const ::atom & atom) const
1835//{
1836//
1837// string_base < TYPE_CHAR > str(*this);
1838//
1839// str += atom;
1840//
1841// return str;
1842//
1843//}
1844
1845
1846//template < prototype_character CHARACTER, character_count sizeMaximumLength >
1847//inline ::string_base < const CHARACTER * > operator +(const inline_string < CHARACTER, sizeMaximumLength > & inlinestring, const ::atom & atom)
1848//{
1849//
1850// return ::string_base< const CHARACTER *>(inlinestring) + ::string_base< const CHARACTER *>(atom);
1851//
1852//}
1853
1854
1855//inline ::string operator +(const_char_pointer psz, const ::atom & atom)
1856//{
1857//
1858// return ::string(scopedstr) + atom.as_string();
1859//
1860//}
1861
1862
1863//inline ::string operator +(const ::scoped_string & scopedstr, const ::atom & atom)
1864//{
1865//
1866// return str + atom.as_string();
1867//
1868//}
1869
1870
1871//template < ::collection::count c >
1872//inline ::string operator +(const ::i8(&sz)[c], const ::atom & atom)
1873//{
1874//
1875// return ::string(sz) + atom.as_string();
1876//
1877//}
1878
1879
1880//template < prototype_character CHARACTER, prototype_character CHARACTER2 >
1881//inline ::string_base<CHARACTER2> operator +(const ::range < CHARACTER > & block, const ::string_base < CHARACTER2 > & str)
1882//{
1883//
1884// return ::string_base<CHARACTER2>(block) + str;
1885//
1886//}
1887
1888//template < prototype_character CHARACTER >
1889//inline ::string_base < CHARACTER > & operator +=(::string_base < CHARACTER > & str, const ::atom & atom)
1890//{
1891//
1892// return str.operator += ((::string) atom);
1893//
1894//}
1895
1896
1897//template < typename ITERATOR_TYPE >
1898//inline string_base < ITERATOR_TYPE >::string_base(const ::atom & atom) :
1899// string_base(atom.as_string())
1900//{
1901//
1902//
1903//}
1904//
1905
1906//template < typename ITERATOR_TYPE >
1907//inline const_string_range < ITERATOR_TYPE >::const_string_range(const atom & atom)
1908//{
1909//
1910//
1911// throw_exception(error_not_supported);
1912//
1913//
1914//}
1915
1916
1917template < prototype_payload PAYLOAD >
1918atom::atom(const PAYLOAD & payload)
1919{
1920
1921 m_etype = e_type_integer;
1922
1923 m_uLargest = 0;
1924
1925 if (payload.is_null())
1926 {
1927
1928 operator = (e_type_null);
1929
1930 }
1931 else if (payload.is_empty())
1932 {
1933
1934 operator = (e_type_empty);
1935
1936 }
1937 else if (payload.get_type() == ::e_type_atom)
1938 {
1939
1940 operator = (payload.as_atom());
1941
1942 }
1943// else if (payload.get_type() == ::e_type_enum_command)
1944// {
1945//
1946// operator = (payload.m_ecommand);
1947//
1948// }
1949 else if (payload.is_integer())
1950 {
1951
1952 operator = (payload.as_iptr());
1953
1954 }
1955 else
1956 {
1957
1958 operator = (payload.as_string());
1959
1960 }
1961
1962}
1963
1964
1965
1966//template < has_as_string_not_payload HAS_AS_STRING_NOT_PAYLOAD >
1967//atom::atom(const HAS_AS_STRING_NOT_PAYLOAD & has_as_string_not_payload) :
1968// m_str(has_as_string_not_payload)
1969//{
1970//
1971// m_etype = e_type_text;
1972//
1973//}
1974
1975
1976inline ::string atom::operator +(const_char_pointer psz) const
1977{
1978
1979 return this->as_string() + psz;
1980
1981}
1982
1983
1984inline ::string atom::operator +(const ::scoped_string & scopedstr) const
1985{
1986
1987 return this->as_string() + scopedstr;
1988
1989}
1990
1991
1992template < character_count n >
1993inline bool atom::operator == (const ::ansi_character (&cha)[n]) const
1994{
1995
1996 return *this == ::scoped_string(cha);
1997
1998}
1999
2000
2001template < character_count n >
2002inline ::std::strong_ordering atom::operator <=> (const ::ansi_character (&cha)[n]) const
2003{
2004
2005 return *this <=> ::scoped_string(cha);
2006
2007}
2008
2009//
2010//template<prototype_character_range RANGE>
2011//inline atom::atom(const RANGE &range) : m_str(range)
2012//{
2013//
2014// m_etype = e_type_text;
2015//}
Definition atom.h:237
class of operations on a range of characters that are not changed. m_begin, m_end or m_erange should ...
Definition const_string_range.h:82
Definition payload.h:54
Definition range.h:223
Definition block.h:46
Definition compare.h:266