Skip to content

Commit

Permalink
add string conversion for primitive type
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf committed Mar 19, 2018
1 parent b75379a commit 1674d1b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/shogun/lib/DataType.cpp
Expand Up @@ -15,6 +15,26 @@

using namespace shogun;

namespace shogun
{
std::string ptype(EPrimitiveType pt)
{
switch (pt)
{
case PT_BOOL: return "BOOL";
case PT_CHAR: return "CHAR";
case PT_INT32: return "INT32";
case PT_INT64: return "INT64";
case PT_FLOAT32: return "FLOAT32";
case PT_FLOAT64: return "FLOAT64";
case PT_SGOBJECT: return "SGOBJECT";
default:
SG_SNOTIMPLEMENTED
return "UNKNOWN";
}
}
}

TSGDataType::TSGDataType(EContainerType ctype, EStructType stype,
EPrimitiveType ptype)
{
Expand Down
8 changes: 7 additions & 1 deletion src/shogun/lib/DataType.h
Expand Up @@ -10,7 +10,7 @@
#define __DATATYPE_H__

#include <shogun/lib/config.h>

#include <shogun/io/SGIO.h>
#include <shogun/lib/common.h>

#define PT_NOT_GENERIC PT_SGOBJECT
Expand Down Expand Up @@ -57,6 +57,12 @@ enum EPrimitiveType
PT_COMPLEX128=14,
PT_UNDEFINED=15
};

/** Returns string representation of primitive type
* @param pt primitive type
* @return string for primitive type
*/
std::string ptype(EPrimitiveType pt);
#endif

/** @brief Datatypes that shogun supports. */
Expand Down

0 comments on commit 1674d1b

Please sign in to comment.