1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 * Author : Ivan DUTKA-MALEN - EDF R&D
26 * Date : September 2003
33 #include "Defines.hxx"
38 #include "GenericType.hxx"
39 #include "BoolType.hxx"
40 #include "LongType.hxx"
41 #include "StringType.hxx"
42 #include "CoupleType.hxx"
43 #include "TypeMismatchException.hxx"
44 #include "ListIsFullException.hxx"
45 #include "RunTimeException.hxx"
50 enum DiscriminatorType { BOOL, LONG, STRING, COUPLE };
52 class BATCH_EXPORT Versatile : public std::list< GenericType * >
57 Versatile(DiscriminatorType discriminator, size_type maxsize, std::string name);
58 Versatile(const Versatile & V);
60 // Use of default constructor is forbidden but we cannot declare it private because
61 // compilation fails with VC8 on Windows
62 Versatile() { throw RunTimeException("Forbidden constructor"); }
67 // Affectation and concatenation operators from base types
68 Versatile & operator = (const long l);
69 Versatile & operator = (const std::string & ch);
70 Versatile & operator +=(const std::string & ch);
71 Versatile & operator , (const std::string & ch);
72 Versatile & operator = (const char * ch);
73 Versatile & operator +=(const char * ch);
74 Versatile & operator , (const char * ch);
75 Versatile & operator = (const Couple & cp);
76 Versatile & operator +=(const Couple & cp);
77 Versatile & operator , (const Couple & cp);
78 Versatile & operator = (const int i);
79 Versatile & operator = (const bool b);
81 // Type conversion to base types
82 operator long() const;
83 operator std::string() const;
84 operator Couple() const;
85 std::string str() const;
86 operator bool() const;
89 // Display on a stream
90 BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const Versatile & );
93 void checkType(DiscriminatorType t) const;
96 DiscriminatorType getType() const;
97 size_type getMaxSize() const;
98 const std::string & getName() const;
100 // Erase all internal elements
105 DiscriminatorType _discriminator; // Internal element type
106 size_type _maxsize; // Maximum number of internal elements
107 std::string _name; // Object name (used for exceptions)
111 // Forbid the use of assignment operator
112 void operator= (const Versatile &) {}