blob: f663d82e4d9ec62b8b26124b46bf02d64f70afbb [file] [log] [blame]
Daniel Espene9fd6952019-10-11 11:01:16 +02001/*
2 * anyTypeChecker.h
3 *
4 * Author: wendel
5 */
6
7#ifndef UTIL_ANYTYPECHECKER_H_
8#define UTIL_ANYTYPECHECKER_H_
9
Tobias Klausmannf13b5e22019-12-13 11:56:37 +010010#include <BaSyx/shared/types.h>
11#include <BaSyx/shared/object.h>
Daniel Espene9fd6952019-10-11 11:01:16 +020012
13#include <string>
14
15namespace basyx {
16
17namespace PropertyTypeInfo
18{
Thomas Psota79a97d62019-11-25 15:33:10 +010019 static constexpr char STRING[] = "string";
20 static constexpr char INT[] = "int";
21 static constexpr char COLLECTION[] = "collection";
22 static constexpr char MAP[] = "map";
23 static constexpr char BOOL[] = "boolean";
24 static constexpr char DOUBLE[] = "double";
25 static constexpr char FLOAT[] = "long";
26 static constexpr char PROPNULL[] = "null";
27 static constexpr char NONETYPE[] = "Type not specified";
Daniel Espene9fd6952019-10-11 11:01:16 +020028}
29
30
Johannes Wendeled007a12019-11-25 17:09:45 +010031static std::string getPropertyTypeInfo(const basyx::object & object)
Daniel Espene9fd6952019-10-11 11:01:16 +020032{
33 if ( object.InstanceOf<std::string>() )
34 return PropertyTypeInfo::STRING;
35 if ( object.InstanceOf<int>() )
36 return PropertyTypeInfo::INT;
Johannes Wendeled007a12019-11-25 17:09:45 +010037 if ( object.InstanceOf<basyx::object::object_list_t>() )
Daniel Espene9fd6952019-10-11 11:01:16 +020038 return PropertyTypeInfo::COLLECTION;
Johannes Wendeled007a12019-11-25 17:09:45 +010039 if ( object.InstanceOf<basyx::object::object_map_t>() )
Daniel Espene9fd6952019-10-11 11:01:16 +020040 return PropertyTypeInfo::MAP;
41 if ( object.InstanceOf<bool>() )
42 return PropertyTypeInfo::BOOL;
43 if ( object.InstanceOf<double>() )
44 return PropertyTypeInfo::DOUBLE;
45 if ( object.InstanceOf<float>() )
46 return PropertyTypeInfo::FLOAT;
47 if ( object.InstanceOf<std::nullptr_t>() )
48 return PropertyTypeInfo::PROPNULL;
49 return PropertyTypeInfo::NONETYPE;
50}
51
52}
53
54
55#endif // !UTIL_ANYTYPECHECKER_H_