PCL
Variant.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/Variant.h - Released 2024-06-18T15:48:54Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_Variant_h
53 #define __PCL_Variant_h
54 
56 
57 #include <pcl/Defs.h>
58 #include <pcl/Diagnostics.h>
59 
60 #include <pcl/ByteArray.h>
61 #include <pcl/Complex.h>
62 #include <pcl/Matrix.h>
63 #include <pcl/Point.h>
64 #include <pcl/Rectangle.h>
65 #include <pcl/StringList.h>
66 #include <pcl/TimePoint.h>
67 #include <pcl/Vector.h>
68 
69 namespace pcl
70 {
71 
72 // ----------------------------------------------------------------------------
73 
168 namespace VariantType
169 {
170  enum value_type
171  {
172  Invalid = 0,
173 
174  Bool,
175  Boolean = Bool,
176 
177  Int8,
178  Char = Int8,
179  Int16,
180  Short = Int16,
181  Int32,
182  Integer = Int32,
183  Int64,
184 
185  UInt8,
186  Byte = UInt8,
187  UInt16,
188  UShort = UInt16,
189  UInt32,
190  UInt = UInt32,
191  UInt64,
192 
193  Float32,
194  Float = Float32,
195  Float64,
196  Double = Float64,
197  Real = Double,
198 
199  Complex32,
200  FComplex = Complex32,
201  Complex64,
202  DComplex = Complex64,
203  Complex = DComplex,
204 
205  TimePoint,
206 
207  I32Point,
208  Point = I32Point,
209  F32Point,
210  FPoint = F32Point,
211  F64Point,
212  DPoint = F64Point,
213 
214  I32Rect,
215  Rect = I32Rect,
216  F32Rect,
217  FRect = F32Rect,
218  F64Rect,
219  DRect = F64Rect,
220 
221  I8Vector,
223  UI8Vector,
225  I16Vector,
226  UI16Vector,
227  I32Vector,
228  IVector = I32Vector,
229  UI32Vector,
231  I64Vector,
232  UI64Vector,
233  F32Vector,
234  FVector = F32Vector,
235  F64Vector,
236  DVector = F64Vector,
237  C32Vector,
238  C64Vector,
239 
240  I8Matrix,
242  UI8Matrix,
244  I16Matrix,
245  UI16Matrix,
246  I32Matrix,
247  IMatrix = I32Matrix,
248  UI32Matrix,
250  I64Matrix,
251  UI64Matrix,
252  F32Matrix,
253  FMatrix = F32Matrix,
254  F64Matrix,
255  DMatrix = F64Matrix,
256  C32Matrix,
257  C64Matrix,
258 
259  ByteArray,
260 
261  String,
262  IsoString,
263 
264  StringList,
266 
269 
272 
273  NumberOfVariantTypes,
274 
275  FirstCustomType = 1024
276  };
277 }
278 
279 // ----------------------------------------------------------------------------
280 
331 class PCL_CLASS Variant
332 {
333 public:
334 
338  using data_type = VariantType::value_type;
339 
344  : m_type( VariantType::Invalid )
345  {
346  m_data.anyValue = 0;
347  }
348 
352  Variant( bool b )
353  : m_type( VariantType::Bool )
354  {
355  m_data.boolValue = b;
356  }
357 
361  Variant( int8 i8 )
362  : m_type( VariantType::Int8 )
363  {
364  m_data.int8Value = i8;
365  }
366 
370  Variant( int16 i16 )
371  : m_type( VariantType::Int16 )
372  {
373  m_data.int16Value = i16;
374  }
375 
379  Variant( int32 i32 )
380  : m_type( VariantType::Int32 )
381  {
382  m_data.int32Value = i32;
383  }
384 
388  Variant( int64 i64 )
389  : m_type( VariantType::Int64 )
390  {
391  m_data.int64Value = i64;
392  }
393 
398  : m_type( VariantType::UInt8 )
399  {
400  m_data.uint8Value = u8;
401  }
402 
407  : m_type( VariantType::UInt16 )
408  {
409  m_data.uint16Value = u16;
410  }
411 
415  Variant( uint32 u32 ) : m_type( VariantType::UInt32 )
416  {
417  m_data.uint32Value = u32;
418  }
419 
424  : m_type( VariantType::UInt64 )
425  {
426  m_data.uint64Value = u64;
427  }
428 
433  Variant( float f )
434  : m_type( VariantType::Float )
435  {
436  m_data.float32Value = f;
437  }
438 
443  Variant( double d )
444  : m_type( VariantType::Double )
445  {
446  m_data.float64Value = d;
447  }
448 
454  : m_type( VariantType::FComplex )
455  {
456  m_data.anyValue = 0;
457  m_data.complex32Value = new fcomplex( fc );
458  }
459 
465  : m_type( VariantType::DComplex )
466  {
467  m_data.anyValue = 0;
468  m_data.complex64Value = new dcomplex( dc );
469  }
470 
474  Variant( const TimePoint& t )
475  : m_type( VariantType::TimePoint )
476  {
477  m_data.anyValue = 0;
478  m_data.timePointValue = new TimePoint( t );
479  }
480 
485  Variant( const Point& p )
486  : m_type( VariantType::Point )
487  {
488  m_data.anyValue = 0;
489  m_data.i32PointValue = new Point( p );
490  }
491 
496  Variant( const FPoint& fp )
497  : m_type( VariantType::FPoint )
498  {
499  m_data.anyValue = 0;
500  m_data.f32PointValue = new FPoint( fp );
501  }
502 
507  Variant( const DPoint& dp )
508  : m_type( VariantType::DPoint )
509  {
510  m_data.anyValue = 0;
511  m_data.f64PointValue = new DPoint( dp );
512  }
513 
518  Variant( const Rect& r )
519  : m_type( VariantType::Rect )
520  {
521  m_data.anyValue = 0;
522  m_data.i32RectValue = new Rect( r );
523  }
524 
529  Variant( const FRect& fr )
530  : m_type( VariantType::FRect )
531  {
532  m_data.anyValue = 0;
533  m_data.f32RectValue = new FRect( fr );
534  }
535 
540  Variant( const DRect& dr )
541  : m_type( VariantType::DRect )
542  {
543  m_data.anyValue = 0;
544  m_data.f64RectValue = new DRect( dr );
545  }
546 
551  Variant( const CharVector& cv )
552  : m_type( VariantType::CharVector )
553  {
554  m_data.anyValue = 0;
555  m_data.i8VectorValue = new CharVector( cv );
556  }
557 
562  Variant( const ByteVector& bv )
563  : m_type( VariantType::ByteVector )
564  {
565  m_data.anyValue = 0;
566  m_data.ui8VectorValue = new ByteVector( bv );
567  }
568 
573  Variant( const I16Vector& i16v )
574  : m_type( VariantType::I16Vector )
575  {
576  m_data.anyValue = 0;
577  m_data.i16VectorValue = new I16Vector( i16v );
578  }
579 
584  Variant( const UI16Vector& ui16v )
585  : m_type( VariantType::UI16Vector )
586  {
587  m_data.anyValue = 0;
588  m_data.ui16VectorValue = new UI16Vector( ui16v );
589  }
590 
595  Variant( const IVector& iv )
596  : m_type( VariantType::IVector )
597  {
598  m_data.anyValue = 0;
599  m_data.i32VectorValue = new IVector( iv );
600  }
601 
606  Variant( const UIVector& uiv )
607  : m_type( VariantType::UIVector )
608  {
609  m_data.anyValue = 0;
610  m_data.ui32VectorValue = new UIVector( uiv );
611  }
612 
617  Variant( const I64Vector& i64v )
618  : m_type( VariantType::I64Vector )
619  {
620  m_data.anyValue = 0;
621  m_data.i64VectorValue = new I64Vector( i64v );
622  }
623 
628  Variant( const UI64Vector& ui64v )
629  : m_type( VariantType::UI64Vector )
630  {
631  m_data.anyValue = 0;
632  m_data.ui64VectorValue = new UI64Vector( ui64v );
633  }
634 
639  Variant( const FVector& fv )
640  : m_type( VariantType::FVector )
641  {
642  m_data.anyValue = 0;
643  m_data.f32VectorValue = new FVector( fv );
644  }
645 
650  Variant( const DVector& dv )
651  : m_type( VariantType::DVector )
652  {
653  m_data.anyValue = 0;
654  m_data.f64VectorValue = new DVector( dv );
655  }
656 
661  Variant( const C32Vector& c32v )
662  : m_type( VariantType::C32Vector )
663  {
664  m_data.anyValue = 0;
665  m_data.c32VectorValue = new C32Vector( c32v );
666  }
667 
672  Variant( const C64Vector& c64v )
673  : m_type( VariantType::C64Vector )
674  {
675  m_data.anyValue = 0;
676  m_data.c64VectorValue = new C64Vector( c64v );
677  }
678 
683  Variant( const CharMatrix& cm )
684  : m_type( VariantType::CharMatrix )
685  {
686  m_data.anyValue = 0;
687  m_data.i8MatrixValue = new CharMatrix( cm );
688  }
689 
694  Variant( const ByteMatrix& bm )
695  : m_type( VariantType::ByteMatrix )
696  {
697  m_data.anyValue = 0;
698  m_data.ui8MatrixValue = new ByteMatrix( bm );
699  }
700 
705  Variant( const I16Matrix& i16m )
706  : m_type( VariantType::I16Matrix )
707  {
708  m_data.anyValue = 0;
709  m_data.i16MatrixValue = new I16Matrix( i16m );
710  }
711 
716  Variant( const UI16Matrix& ui16m )
717  : m_type( VariantType::UI16Matrix )
718  {
719  m_data.anyValue = 0;
720  m_data.ui16MatrixValue = new UI16Matrix( ui16m );
721  }
722 
727  Variant( const IMatrix& im )
728  : m_type( VariantType::IMatrix )
729  {
730  m_data.anyValue = 0;
731  m_data.i32MatrixValue = new IMatrix( im );
732  }
733 
738  Variant( const UIMatrix& uim )
739  : m_type( VariantType::UIMatrix )
740  {
741  m_data.anyValue = 0;
742  m_data.ui32MatrixValue = new UIMatrix( uim );
743  }
744 
749  Variant( const I64Matrix& i64m )
750  : m_type( VariantType::I64Matrix )
751  {
752  m_data.anyValue = 0;
753  m_data.i64MatrixValue = new I64Matrix( i64m );
754  }
755 
760  Variant( const UI64Matrix& ui64m )
761  : m_type( VariantType::UI64Matrix )
762  {
763  m_data.anyValue = 0;
764  m_data.ui64MatrixValue = new UI64Matrix( ui64m );
765  }
766 
771  Variant( const FMatrix& fm )
772  : m_type( VariantType::FMatrix )
773  {
774  m_data.anyValue = 0;
775  m_data.f32MatrixValue = new FMatrix( fm );
776  }
777 
782  Variant( const DMatrix& dm )
783  : m_type( VariantType::DMatrix )
784  {
785  m_data.anyValue = 0;
786  m_data.f64MatrixValue = new DMatrix( dm );
787  }
788 
793  Variant( const C32Matrix& c32m )
794  : m_type( VariantType::C32Matrix )
795  {
796  m_data.anyValue = 0;
797  m_data.c32MatrixValue = new C32Matrix( c32m );
798  }
799 
804  Variant( const C64Matrix& c64m )
805  : m_type( VariantType::C64Matrix )
806  {
807  m_data.anyValue = 0;
808  m_data.c64MatrixValue = new C64Matrix( c64m );
809  }
810 
815  Variant( const ByteArray& ba )
816  : m_type( VariantType::ByteArray )
817  {
818  m_data.anyValue = 0;
819  m_data.byteArrayValue = new ByteArray( ba );
820  }
821 
825  Variant( const String& s )
826  : m_type( VariantType::String )
827  {
828  m_data.anyValue = 0;
829  m_data.stringValue = new String( s );
830  }
831 
836  Variant( const IsoString& s8 )
837  : m_type( VariantType::IsoString )
838  {
839  m_data.anyValue = 0;
840  m_data.isoStringValue = new IsoString( s8 );
841  }
842 
847  Variant( const char* cp )
848  : m_type( VariantType::IsoString )
849  {
850  m_data.anyValue = 0;
851  m_data.isoStringValue = new IsoString( cp );
852  }
853 
858  Variant( const StringList& sl )
859  : m_type( VariantType::StringList )
860  {
861  m_data.anyValue = 0;
862  m_data.stringListValue = new StringList( sl );
863  }
864 
869  Variant( const IsoStringList& isl )
870  : m_type( VariantType::IsoStringList )
871  {
872  m_data.anyValue = 0;
873  m_data.isoStringListValue = new IsoStringList( isl );
874  }
875 
880  Variant( const StringKeyValue& skv )
881  : m_type( VariantType::StringKeyValue )
882  {
883  m_data.anyValue = 0;
884  m_data.stringKeyValueValue = new StringKeyValue( skv );
885  }
886 
891  Variant( const IsoStringKeyValue& iskv )
892  : m_type( VariantType::IsoStringKeyValue )
893  {
894  m_data.anyValue = 0;
895  m_data.isoStringKeyValueValue = new IsoStringKeyValue( iskv );
896  }
897 
903  : m_type( VariantType::StringKeyValueList )
904  {
905  m_data.anyValue = 0;
906  m_data.stringKeyValueListValue = new StringKeyValueList( skvl );
907  }
908 
914  : m_type( VariantType::IsoStringKeyValueList )
915  {
916  m_data.anyValue = 0;
917  m_data.isoStringKeyValueListValue = new IsoStringKeyValueList( iskvl );
918  }
919 
924  Variant( const Variant& x )
925  : m_type( VariantType::Invalid )
926  {
927  m_data.anyValue = 0;
928  Copy( x );
929  }
930 
935  {
936  m_type = x.m_type;
937  m_data.anyValue = x.m_data.anyValue;
938  x.m_type = VariantType::Invalid;
939  }
940 
944  virtual ~Variant()
945  {
946  Clear();
947  }
948 
953  Variant& operator =( const Variant& x )
954  {
955  Assign( x );
956  return *this;
957  }
958 
963  void Assign( const Variant& x )
964  {
965  if ( &x != this )
966  {
967  Clear();
968  Copy( x );
969  }
970  }
971 
975  Variant& operator =( Variant&& x )
976  {
977  Transfer( x );
978  return *this;
979  }
980 
985  void Transfer( Variant& x )
986  {
987  if ( &x != this )
988  {
989  Clear();
990  m_type = x.m_type;
991  m_data.anyValue = x.m_data.anyValue;
992  x.m_type = VariantType::Invalid;
993  }
994  }
995 
1000  void Transfer( Variant&& x )
1001  {
1002  if ( &x != this )
1003  {
1004  Clear();
1005  m_type = x.m_type;
1006  m_data.anyValue = x.m_data.anyValue;
1007  x.m_type = VariantType::Invalid;
1008  }
1009  }
1010 
1015  bool IsValid() const
1016  {
1017  return m_type != VariantType::Invalid;
1018  }
1019 
1023  data_type Type() const
1024  {
1025  return data_type( m_type );
1026  }
1027 
1038  Variant ToType( data_type type ) const;
1039 
1044  void Clear();
1045 
1064  int Compare( const Variant& x ) const;
1065 
1074  bool operator ==( const Variant& x ) const
1075  {
1076  return Compare( x ) == 0;
1077  }
1078 
1087  bool operator <( const Variant& x ) const
1088  {
1089  return Compare( x ) < 0;
1090  }
1091 
1099  bool ToBool() const;
1100 
1105  bool CanConvertToBool() const noexcept;
1106 
1110  bool ToBoolean() const
1111  {
1112  return ToBool();
1113  }
1114 
1118  bool CanConvertToBoolean() const noexcept
1119  {
1120  return CanConvertToBool();
1121  }
1122 
1130  int ToInt() const;
1131 
1136  bool CanConvertToInt() const noexcept;
1137 
1145  int64 ToInt64() const;
1146 
1151  bool CanConvertToInt64() const noexcept;
1152 
1160  unsigned int ToUInt() const;
1161 
1166  bool CanConvertToUInt() const noexcept;
1167 
1175  uint64 ToUInt64() const;
1176 
1181  bool CanConvertToUInt64() const noexcept;
1182 
1190  float ToFloat() const;
1191 
1196  bool CanConvertToFloat() const noexcept;
1197 
1205  double ToDouble() const;
1206 
1211  bool CanConvertToDouble() const noexcept;
1212 
1220  fcomplex ToFComplex() const;
1221 
1226  bool CanConvertToFComplex() const noexcept;
1227 
1235  dcomplex ToDComplex() const;
1236 
1241  bool CanConvertToDComplex() const noexcept;
1242 
1246  complex ToComplex() const
1247  {
1248  return ToDComplex();
1249  }
1250 
1254  bool CanConvertToComplex() const noexcept
1255  {
1256  return CanConvertToDComplex();
1257  }
1258 
1267 
1272  bool CanConvertToTimePoint() const noexcept;
1273 
1281  Point ToPoint() const;
1282 
1287  bool CanConvertToPoint() const noexcept;
1288 
1296  FPoint ToFPoint() const;
1297 
1302  bool CanConvertToFPoint() const noexcept;
1303 
1311  DPoint ToDPoint() const;
1312 
1317  bool CanConvertToDPoint() const noexcept;
1318 
1327  Rect ToRect() const;
1328 
1333  bool CanConvertToRect() const noexcept;
1334 
1343  FRect ToFRect() const;
1344 
1349  bool CanConvertToFRect() const noexcept;
1350 
1359  DRect ToDRect() const;
1360 
1365  bool CanConvertToDRect() const noexcept;
1366 
1374  CharVector ToCharVector() const;
1375 
1380  bool CanConvertToCharVector() const noexcept;
1381 
1389  ByteVector ToByteVector() const;
1390 
1395  bool CanConvertToByteVector() const noexcept;
1396 
1404  I16Vector ToI16Vector() const;
1405 
1410  bool CanConvertToI16Vector() const noexcept;
1411 
1419  UI16Vector ToUI16Vector() const;
1420 
1425  bool CanConvertToUI16Vector() const noexcept;
1426 
1434  IVector ToIVector() const;
1435 
1440  bool CanConvertToIVector() const noexcept;
1441 
1449  UIVector ToUIVector() const;
1450 
1455  bool CanConvertToUIVector() const noexcept;
1456 
1464  I64Vector ToI64Vector() const;
1465 
1470  bool CanConvertToI64Vector() const noexcept;
1471 
1479  UI64Vector ToUI64Vector() const;
1480 
1485  bool CanConvertToUI64Vector() const noexcept;
1486 
1494  FVector ToFVector() const;
1495 
1500  bool CanConvertToFVector() const noexcept;
1501 
1509  DVector ToDVector() const;
1510 
1515  bool CanConvertToDVector() const noexcept;
1516 
1520  Vector ToVector() const
1521  {
1522  return ToDVector();
1523  }
1524 
1528  bool CanConvertToVector() const noexcept
1529  {
1530  return CanConvertToDVector();
1531  }
1532 
1542 
1547  bool CanConvertToC32Vector() const noexcept;
1548 
1557  C64Vector ToC64Vector() const;
1558 
1563  bool CanConvertToC64Vector() const noexcept;
1564 
1572  CharMatrix ToCharMatrix() const;
1573 
1578  bool CanConvertToCharMatrix() const noexcept;
1579 
1587  ByteMatrix ToByteMatrix() const;
1588 
1593  bool CanConvertToByteMatrix() const noexcept;
1594 
1602  I16Matrix ToI16Matrix() const;
1603 
1608  bool CanConvertToI16Matrix() const noexcept;
1609 
1617  UI16Matrix ToUI16Matrix() const;
1618 
1623  bool CanConvertToUI16Matrix() const noexcept;
1624 
1632  IMatrix ToIMatrix() const;
1633 
1638  bool CanConvertToIMatrix() const noexcept;
1639 
1647  UIMatrix ToUIMatrix() const;
1648 
1653  bool CanConvertToUIMatrix() const noexcept;
1654 
1662  I64Matrix ToI64Matrix() const;
1663 
1668  bool CanConvertToI64Matrix() const noexcept;
1669 
1677  UI64Matrix ToUI64Matrix() const;
1678 
1683  bool CanConvertToUI64Matrix() const noexcept;
1684 
1692  FMatrix ToFMatrix() const;
1693 
1698  bool CanConvertToFMatrix() const noexcept;
1699 
1707  DMatrix ToDMatrix() const;
1708 
1713  bool CanConvertToDMatrix() const noexcept;
1714 
1718  Matrix ToMatrix() const
1719  {
1720  return ToDMatrix();
1721  }
1722 
1726  bool CanConvertToMatrix() const noexcept
1727  {
1728  return CanConvertToDMatrix();
1729  }
1730 
1740 
1745  bool CanConvertToC32Matrix() const noexcept;
1746 
1755  C64Matrix ToC64Matrix() const;
1756 
1761  bool CanConvertToC64Matrix() const noexcept;
1762 
1770  ByteArray ToByteArray() const;
1771 
1776  bool CanConvertToByteArray() const noexcept;
1777 
1785  String ToString() const;
1786 
1791  bool CanConvertToString() const noexcept;
1792 
1800  IsoString ToIsoString() const;
1801 
1806  bool CanConvertToIsoString() const noexcept;
1807 
1815  StringList ToStringList() const;
1816 
1821  bool CanConvertToStringList() const noexcept;
1822 
1830  IsoStringList ToIsoStringList() const;
1831 
1836  bool CanConvertToIsoStringList() const noexcept;
1837 
1845  StringKeyValue ToStringKeyValue() const;
1846 
1854  IsoStringKeyValue ToIsoStringKeyValue() const;
1855 
1864  StringKeyValueList ToStringKeyValueList() const;
1865 
1874  IsoStringKeyValueList ToIsoStringKeyValueList() const;
1875 
1891  const void* InternalBlockAddress() const;
1892 
1900  size_type VectorLength() const;
1901 
1913  Rect MatrixDimensions() const;
1914 
1925  size_type BlockSize() const;
1926 
1933  static int BytesPerBlockElementForType( int type );
1934 
1942  int BytesPerBlockElement() const
1943  {
1944  return BytesPerBlockElementForType( m_type );
1945  }
1946 
1952  static bool IsScalarType( int type );
1953 
1959  bool IsScalar() const
1960  {
1961  return IsScalarType( m_type );
1962  }
1963 
1968  static bool IsComplexType( int type )
1969  {
1970  return type == VariantType::Complex32 || type == VariantType::Complex64;
1971  }
1972 
1977  bool IsComplex() const
1978  {
1979  return IsComplexType( m_type );
1980  }
1981 
1985  static bool IsTimePointType( int type )
1986  {
1987  return type == VariantType::TimePoint;
1988  }
1989 
1994  bool IsTimePoint() const
1995  {
1996  return IsTimePointType( m_type );
1997  }
1998 
2004  static bool IsVectorType( int type );
2005 
2011  bool IsVector() const
2012  {
2013  return IsVectorType( m_type );
2014  }
2015 
2021  static bool IsMatrixType( int type );
2022 
2028  bool IsMatrix() const
2029  {
2030  return IsMatrixType( m_type );
2031  }
2032 
2037  static bool IsStringType( int type )
2038  {
2039  return type == VariantType::String || type == VariantType::IsoString;
2040  }
2041 
2046  bool IsString() const
2047  {
2048  return IsStringType( m_type );
2049  }
2050 
2057  static bool IsStructuredType( int type );
2058 
2069  bool IsStructured() const
2070  {
2071  return IsStructuredType( m_type );
2072  }
2073 
2078  static const char* TypeAsString( int type );
2079 
2080 private:
2081 
2082  union Data
2083  {
2084  bool boolValue;
2085 
2086  int8 int8Value;
2087  int16 int16Value;
2088  int32 int32Value;
2089  int64 int64Value;
2090 
2091  uint8 uint8Value;
2092  uint16 uint16Value;
2093  uint32 uint32Value;
2094  uint64 uint64Value;
2095 
2096  float float32Value;
2097  double float64Value;
2098 
2099  fcomplex* complex32Value;
2100  dcomplex* complex64Value;
2101 
2102  TimePoint* timePointValue;
2103 
2104  I32Point* i32PointValue;
2105  F32Point* f32PointValue;
2106  F64Point* f64PointValue;
2107 
2108  I32Rect* i32RectValue;
2109  F32Rect* f32RectValue;
2110  F64Rect* f64RectValue;
2111 
2112  I8Vector* i8VectorValue;
2113  UI8Vector* ui8VectorValue;
2114  I16Vector* i16VectorValue;
2115  UI16Vector* ui16VectorValue;
2116  I32Vector* i32VectorValue;
2117  UI32Vector* ui32VectorValue;
2118  I64Vector* i64VectorValue;
2119  UI64Vector* ui64VectorValue;
2120  F32Vector* f32VectorValue;
2121  F64Vector* f64VectorValue;
2122  C32Vector* c32VectorValue;
2123  C64Vector* c64VectorValue;
2124 
2125  I8Matrix* i8MatrixValue;
2126  UI8Matrix* ui8MatrixValue;
2127  I16Matrix* i16MatrixValue;
2128  UI16Matrix* ui16MatrixValue;
2129  I32Matrix* i32MatrixValue;
2130  UI32Matrix* ui32MatrixValue;
2131  I64Matrix* i64MatrixValue;
2132  UI64Matrix* ui64MatrixValue;
2133  F32Matrix* f32MatrixValue;
2134  F64Matrix* f64MatrixValue;
2135  C32Matrix* c32MatrixValue;
2136  C64Matrix* c64MatrixValue;
2137 
2138  ByteArray* byteArrayValue;
2139 
2140  String* stringValue;
2141  IsoString* isoStringValue;
2142 
2143  StringList* stringListValue;
2144  IsoStringList* isoStringListValue;
2145 
2146  StringKeyValue* stringKeyValueValue;
2147  IsoStringKeyValue* isoStringKeyValueValue;
2148 
2149  StringKeyValueList* stringKeyValueListValue;
2150  IsoStringKeyValueList* isoStringKeyValueListValue;
2151 
2152  uint64 anyValue;
2153  };
2154 
2155  Data m_data;
2156  int m_type;
2157 
2158  // Internal
2159  void Copy( const Variant& );
2160 
2161  friend class PCL_AssertVariantSize;
2162 };
2163 
2164 class PCL_AssertVariantSize
2165 {
2166 #ifndef _MSC_VER
2167 # ifdef __clang__
2168  _Pragma("clang diagnostic push")
2169  _Pragma("clang diagnostic ignored \"-Wunused-private-field\"")
2170 # endif
2171  Variant* v;
2172  static_assert( sizeof( v->m_data ) == sizeof( uint64 ), "Invalid sizeof( Variant::m_data )" );
2173  static_assert( sizeof( v->m_data.anyValue ) == sizeof( v->m_data ), "Invalid sizeof( Variant::m_data.anyValue )" );
2174 # ifdef __clang__
2175  _Pragma("clang diagnostic pop")
2176 # endif
2177 #else
2178  static_assert( sizeof( Variant::Data ) == sizeof( uint64 ), "Invalid sizeof( Variant::m_data )" );
2179 #endif
2180 };
2181 
2182 // ----------------------------------------------------------------------------
2183 
2184 } // pcl
2185 
2190 struct api_property_value;
2191 namespace pcl
2192 {
2193  Variant VariantFromAPIPropertyValue( const api_property_value& );
2194  void APIPropertyValueFromVariant( api_property_value&, const Variant& );
2195  Variant::data_type VariantTypeFromAPIPropertyType( uint64 );
2196  uint64 APIPropertyTypeFromVariantType( Variant::data_type );
2197 } // pcl
2198 
2199 #endif // __PCL_Variant_h
2200 
2201 // ----------------------------------------------------------------------------
2202 // EOF pcl/Variant.h - Released 2024-06-18T15:48:54Z
Dynamic array of 8-bit unsigned integers.
8-bit unsigned integer matrix.
8-bit unsigned integer vector.
32-bit floating point complex matrix.
32-bit floating point complex vector.
64-bit floating point complex matrix.
64-bit floating point complex vector.
8-bit signed integer matrix.
8-bit signed integer vector.
A complex number whose components are 32-bit floating point real numbers.
A complex number whose components are 64-bit floating point real numbers.
Generic complex number.
Definition: Complex.h:84
64-bit floating point real matrix.
64-bit floating-point point in the R^2 space.
64-bit floating-point rectangle in the R^2 space.
64-bit floating point real vector.
32-bit floating point real matrix.
32-bit floating-point point in the R^2 space.
32-bit floating-point rectangle in the R^2 space.
32-bit floating point real vector.
64-bit floating point real matrix.
64-bit floating-point point in the R^2 space.
64-bit floating-point rectangle in the R^2 space.
64-bit floating point real vector.
32-bit floating point real matrix.
32-bit floating-point point in the R^2 space.
32-bit floating-point rectangle in the R^2 space.
32-bit floating point real vector.
Generic dynamic matrix of arbitrary dimensions.
Definition: Matrix.h:123
A generic point in the two-dimensional space.
Definition: Point.h:100
A generic rectangle in the two-dimensional space.
Definition: Rectangle.h:314
Generic vector of arbitrary length.
Definition: Vector.h:107
16-bit signed integer matrix.
16-bit signed integer vector.
32-bit signed integer matrix.
32-bit integer point on the plane.
32-bit integer rectangle on the plane.
32-bit signed integer vector.
64-bit integer matrix.
64-bit integer vector.
8-bit signed integer matrix.
8-bit signed integer vector.
32-bit signed integer matrix.
32-bit signed integer vector.
Dynamic list of key-value associations implemented as 8-bit strings.
Key-value association of two 8-bit strings.
Dynamic list of 8-bit strings.
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5425
Generic key-value association.
Definition: KeyValue.h:72
32-bit integer point on the plane.
32-bit integer rectangle on the plane.
Dynamic list of key-value associations implemented as Unicode (UTF-16) strings.
Key-value association of two Unicode (UTF-16) strings.
Dynamic list of Unicode (UTF-16) strings.
Unicode (UTF-16) string.
Definition: String.h:8113
An instant in any timescale.
Definition: TimePoint.h:103
16-bit unsigned integer matrix.
16-bit unsigned integer vector.
32-bit unsigned integer matrix.
32-bit unsigned integer vector.
64-bit unsigned integer matrix.
64-bit unsigned integer vector.
8-bit unsigned integer matrix.
8-bit unsigned integer vector.
Unsigned integer matrix.
32-bit unsigned integer vector.
Acts like a union to store instances of different data types.
Definition: Variant.h:332
bool IsScalar() const
Definition: Variant.h:1959
static bool IsComplexType(int type)
Definition: Variant.h:1968
Variant(const StringKeyValueList &skvl)
Definition: Variant.h:902
Variant(const UI16Matrix &ui16m)
Definition: Variant.h:716
Variant(const ByteMatrix &bm)
Definition: Variant.h:694
bool CanConvertToTimePoint() const noexcept
static bool IsStringType(int type)
Definition: Variant.h:2037
Variant(const C64Matrix &c64m)
Definition: Variant.h:804
Variant(const IsoString &s8)
Definition: Variant.h:836
Variant(const Rect &r)
Definition: Variant.h:518
void Transfer(Variant &&x)
Definition: Variant.h:1000
Variant(const DVector &dv)
Definition: Variant.h:650
Variant(const ByteVector &bv)
Definition: Variant.h:562
Variant(const CharVector &cv)
Definition: Variant.h:551
static bool IsVectorType(int type)
void Assign(const Variant &x)
Definition: Variant.h:963
Variant(const String &s)
Definition: Variant.h:825
Variant(const UIMatrix &uim)
Definition: Variant.h:738
bool IsTimePoint() const
Definition: Variant.h:1994
Variant(const UI64Matrix &ui64m)
Definition: Variant.h:760
Variant(const DPoint &dp)
Definition: Variant.h:507
VariantType::value_type data_type
Definition: Variant.h:338
Variant(const ByteArray &ba)
Definition: Variant.h:815
Variant(const IsoStringKeyValue &iskv)
Definition: Variant.h:891
Variant(const UI16Vector &ui16v)
Definition: Variant.h:584
bool CanConvertToBool() const noexcept
Variant(const TimePoint &t)
Definition: Variant.h:474
static bool IsTimePointType(int type)
Definition: Variant.h:1985
Variant(const IMatrix &im)
Definition: Variant.h:727
TimePoint ToTimePoint() const
Variant(const Variant &x)
Definition: Variant.h:924
Variant(const FRect &fr)
Definition: Variant.h:529
Variant(const I64Vector &i64v)
Definition: Variant.h:617
static bool IsMatrixType(int type)
Variant(const char *cp)
Definition: Variant.h:847
Variant(const C32Matrix &c32m)
Definition: Variant.h:793
Variant(int32 i32)
Definition: Variant.h:379
Variant(const CharMatrix &cm)
Definition: Variant.h:683
bool CanConvertToC32Matrix() const noexcept
Variant(const I16Matrix &i16m)
Definition: Variant.h:705
Variant(const DMatrix &dm)
Definition: Variant.h:782
Variant(const FPoint &fp)
Definition: Variant.h:496
bool CanConvertToBoolean() const noexcept
Definition: Variant.h:1118
Variant(const FVector &fv)
Definition: Variant.h:639
static const char * TypeAsString(int type)
Variant(int8 i8)
Definition: Variant.h:361
Variant(Variant &&x)
Definition: Variant.h:934
Variant(const Point &p)
Definition: Variant.h:485
int Compare(const Variant &x) const
Variant(bool b)
Definition: Variant.h:352
virtual ~Variant()
Definition: Variant.h:944
Variant ToType(data_type type) const
Variant(int64 i64)
Definition: Variant.h:388
Variant(const StringList &sl)
Definition: Variant.h:858
bool IsValid() const
Definition: Variant.h:1015
C32Vector ToC32Vector() const
Variant(const I16Vector &i16v)
Definition: Variant.h:573
Variant(const I64Matrix &i64m)
Definition: Variant.h:749
Variant(float f)
Definition: Variant.h:433
data_type Type() const
Definition: Variant.h:1023
bool CanConvertToC32Vector() const noexcept
Variant(int16 i16)
Definition: Variant.h:370
bool IsComplex() const
Definition: Variant.h:1977
bool IsString() const
Definition: Variant.h:2046
Variant(fcomplex fc)
Definition: Variant.h:453
Variant(const DRect &dr)
Definition: Variant.h:540
bool CanConvertToComplex() const noexcept
Definition: Variant.h:1254
Variant(const UI64Vector &ui64v)
Definition: Variant.h:628
void Transfer(Variant &x)
Definition: Variant.h:985
Variant(uint8 u8)
Definition: Variant.h:397
C32Matrix ToC32Matrix() const
Variant(const IVector &iv)
Definition: Variant.h:595
bool CanConvertToMatrix() const noexcept
Definition: Variant.h:1726
Variant(dcomplex dc)
Definition: Variant.h:464
int ToInt() const
Variant(const IsoStringList &isl)
Definition: Variant.h:869
bool IsStructured() const
Definition: Variant.h:2069
Variant(uint64 u64)
Definition: Variant.h:423
static bool IsScalarType(int type)
Variant(const IsoStringKeyValueList &iskvl)
Definition: Variant.h:913
Variant(const StringKeyValue &skv)
Definition: Variant.h:880
Variant(const C32Vector &c32v)
Definition: Variant.h:661
Variant(uint16 u16)
Definition: Variant.h:406
bool CanConvertToInt() const noexcept
bool IsVector() const
Definition: Variant.h:2011
Variant(const C64Vector &c64v)
Definition: Variant.h:672
Variant(double d)
Definition: Variant.h:443
bool ToBool() const
static bool IsStructuredType(int type)
bool IsMatrix() const
Definition: Variant.h:2028
bool CanConvertToVector() const noexcept
Definition: Variant.h:1528
Variant(uint32 u32)
Definition: Variant.h:415
Variant(const UIVector &uiv)
Definition: Variant.h:606
Variant(const FMatrix &fm)
Definition: Variant.h:771
bool operator==(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Definition: Array.h:2267
bool operator<(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Definition: Array.h:2278
signed char int8
Definition: Defs.h:636
unsigned long long uint64
Definition: Defs.h:682
unsigned short uint16
Definition: Defs.h:654
unsigned char uint8
Definition: Defs.h:642
signed short int16
Definition: Defs.h:648
signed long long int64
Definition: Defs.h:676
signed int int32
Definition: Defs.h:660
unsigned int uint32
Definition: Defs.h:666
size_t size_type
Definition: Defs.h:609
int Compare(FI1 i1, FI1 j1, FI2 i2, FI2 j2) noexcept
Definition: Utility.h:639
PCL root namespace.
Definition: AbstractImage.h:77