Turned DrawUtil into class with static methods.

This commit is contained in:
Ian Rees
2016-05-06 23:54:04 +12:00
committed by wmayer
parent 1c98fc39f1
commit d12dbd8f56
6 changed files with 49 additions and 49 deletions

View File

@@ -41,15 +41,11 @@
#include "DrawUtil.h"
namespace DrawUtil {
using namespace TechDraw;
//==============================================================================
// convenient utility functions for TechDraw Module
//==============================================================================
extern "C" {
int TechDrawExport getIndexFromName(std::string geomName)
/*static*/ int DrawUtil::getIndexFromName(std::string geomName)
{
boost::regex re("\\d+$"); //one of more digits at end of string
boost::regex re("\\d+$"); // one of more digits at end of string
boost::match_results<std::string::const_iterator> what;
boost::match_flag_type flags = boost::match_default;
char* endChar;
@@ -69,7 +65,7 @@ int TechDrawExport getIndexFromName(std::string geomName)
}
}
std::string TechDrawExport getGeomTypeFromName(std::string geomName)
std::string DrawUtil::getGeomTypeFromName(std::string geomName)
{
boost::regex re("^[a-zA-Z]*"); //one or more letters at start of string
boost::match_results<std::string::const_iterator> what;
@@ -90,11 +86,10 @@ std::string TechDrawExport getGeomTypeFromName(std::string geomName)
}
}
std::string TechDrawExport makeGeomName(std::string geomType, int index)
std::string DrawUtil::makeGeomName(std::string geomType, int index)
{
std::stringstream newName;
newName << geomType << index;
return newName.str();
}
} //end extern "C"
} //end namespace DrawUtil

View File

@@ -23,13 +23,18 @@
#ifndef _DrawUtil_h_
#define _DrawUtil_h_
namespace DrawUtil {
extern "C" {
#include <string>
int getIndexFromName(std::string geomName);
std::string getGeomTypeFromName(std::string geomName);
std::string makeGeomName(std::string geomType, int index);
namespace TechDraw
{
} //end extern "C"
} //end namespace DrawUtil
/// Convenient utility functions for TechDraw Module
class TechDrawExport DrawUtil {
public:
static int getIndexFromName(std::string geomName);
static std::string getGeomTypeFromName(std::string geomName);
static std::string makeGeomName(std::string geomType, int index);
};
} //end namespace TechDraw
#endif