Commit 8b08e697 authored by Kenneth Leiter's avatar Kenneth Leiter

Remove last vestiges of boost dependency.

parent df11c004
......@@ -21,9 +21,11 @@
/* */
/*****************************************************************************/
#include <string.h>
#include <utility>
#include "XdmfAttributeCenter.hpp"
#include "XdmfError.hpp"
#include "XdmfStringUtils.hpp"
std::map<std::string, shared_ptr<const XdmfAttributeCenter>(*)()> XdmfAttributeCenter::mAttributeCenterDefinitions;
......@@ -99,7 +101,7 @@ XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperti
"XdmfAttributeCenter::New");
}
const std::string & centerVal = ConvertToUpper(center->second);
const std::string centerVal = XdmfStringUtils::toUpper(center->second);
std::map<std::string, shared_ptr<const XdmfAttributeCenter>(*)()>::const_iterator returnType = mAttributeCenterDefinitions.find(centerVal);
......
......@@ -24,6 +24,7 @@
#include <utility>
#include "XdmfAttributeType.hpp"
#include "XdmfError.hpp"
#include "XdmfStringUtils.hpp"
std::map<std::string, shared_ptr<const XdmfAttributeType>(*)()> XdmfAttributeType::mAttributeDefinitions;
......@@ -120,7 +121,7 @@ XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties
}
const std::string & typeVal = ConvertToUpper(type->second);
const std::string & typeVal = XdmfStringUtils::toUpper(type->second);
std::map<std::string, shared_ptr<const XdmfAttributeType>(*)()>::const_iterator returnType = mAttributeDefinitions.find(typeVal);
......
......@@ -21,10 +21,11 @@
/* */
/*****************************************************************************/
#include <string.h>
#include <utility>
#include "XdmfGeometryType.hpp"
#include "XdmfError.hpp"
#include "string.h"
#include "XdmfStringUtils.hpp"
std::map<std::string, shared_ptr<const XdmfGeometryType>(*)()> XdmfGeometryType::mGeometryDefinitions;
......@@ -101,7 +102,7 @@ XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
"in XdmfGeometryType::New");
}
const std::string & typeVal = ConvertToUpper(type->second);
const std::string typeVal = XdmfStringUtils::toUpper(type->second);
std::map<std::string, shared_ptr<const XdmfGeometryType>(*)()>::const_iterator returnType
= mGeometryDefinitions.find(typeVal);
......
......@@ -24,6 +24,7 @@
#include <utility>
#include "XdmfError.hpp"
#include "XdmfGridCollectionType.hpp"
#include "XdmfStringUtils.hpp"
std::map<std::string, shared_ptr<const XdmfGridCollectionType>(*)()>
XdmfGridCollectionType::mGridCollectionDefinitions;
......@@ -83,7 +84,7 @@ XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemPrope
"XdmfGridCollectionType::New");
}
const std::string & typeVal = ConvertToUpper(type->second);
const std::string typeVal = XdmfStringUtils::toUpper(type->second);
std::map<std::string, shared_ptr<const XdmfGridCollectionType>(*)()>::const_iterator returnType
= mGridCollectionDefinitions.find(typeVal);
......
......@@ -24,6 +24,7 @@
#include <utility>
#include "XdmfSetType.hpp"
#include "XdmfError.hpp"
#include "XdmfStringUtils.hpp"
std::map<std::string, shared_ptr<const XdmfSetType>(*)()> XdmfSetType::mSetDefinitions;
......@@ -97,7 +98,7 @@ XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
"Neither 'Type' nor 'SetType' found in itemProperties "
"in XdmfSetType::New");
}
const std::string & typeVal = ConvertToUpper(type->second);
const std::string typeVal = XdmfStringUtils::toUpper(type->second);
std::map<std::string, shared_ptr<const XdmfSetType>(*)()>::const_iterator returnType
= mSetDefinitions.find(typeVal);
......
......@@ -24,11 +24,13 @@
#include <cctype>
#include <cmath>
#include <sstream>
#include <string.h>
#include <utility>
#include <vector>
#include "string.h"
#include "XdmfError.hpp"
#include "XdmfTopologyType.hpp"
#include "XdmfStringUtils.hpp"
std::map<std::string, shared_ptr<const XdmfTopologyType>(*)()> XdmfTopologyType::mTopologyDefinitions;
......@@ -695,7 +697,7 @@ XdmfTopologyType::New(const std::map<std::string, std::string> & itemProperties)
"Neither 'Type' nor 'TopologyType' found in "
"itemProperties in XdmfTopologyType::New");
}
std::string typeVal = ConvertToUpper(type->second);
const std::string typeVal = XdmfStringUtils::toUpper(type->second);
std::map<std::string, std::string>::const_iterator nodesPerElement =
itemProperties.find("NodesPerElement");
......
project(XdmfCore)
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.1)
if (POLICY CMP0015)
cmake_policy(SET CMP0015 NEW)
endif ()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(CheckCXXSourceCompiles)
include(SetUpVersion)
include(TestBigEndian)
......@@ -39,13 +42,6 @@ if(XDMF_BUILD_DSM)
option(XDMF_BUILD_DSM_THREADS ON)
endif()
mark_as_advanced(CLEAR Boost_INCLUDE_DIR)
find_package(Boost REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
mark_as_advanced(FORCE Boost_INCLUDE_DIR)
endif()
# Find HDF5_ROOT if not set
if ("$ENV{HDF5_ROOT}" STREQUAL "")
find_file (HDF5_LIB libhdf5.so HINTS ENV LD_LIBRARY_PATH)
......@@ -140,6 +136,7 @@ set(XdmfCoreSources
XdmfPlaceholder
XdmfSparseMatrix
XdmfSubset
XdmfStringUtils
XdmfSystemUtils
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/XdmfVersion
XdmfVisitor
......@@ -288,21 +285,7 @@ if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
ARCHIVE DESTINATION lib)
endif ()
if (Boost_FOUND)
set(FOUND_BOOST_INCLUDES ${Boost_INCLUDE_DIRS})
set(XdmfCore_INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${HDF5_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
CACHE INTERNAL "")
else ()
set(FOUND_BOOST_INCLUDES "")
endif ()
set(XdmfCore_INCLUDE_DIRS
${FOUND_BOOST_INCLUDES}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${HDF5_INCLUDE_DIR}
......
......@@ -27,7 +27,7 @@
#include "XdmfArrayReference.hpp"
#include <stack>
#include <math.h>
#include <boost/assign.hpp>
#include <string.h>
#include "XdmfError.hpp"
XdmfArrayReference::XdmfArrayReference():
......
......@@ -22,11 +22,11 @@
/*****************************************************************************/
#include <sstream>
#include <string.h>
#include <utility>
#include <boost/assign.hpp>
#include "string.h"
#include "XdmfArrayType.hpp"
#include "XdmfError.hpp"
#include "XdmfStringUtils.hpp"
std::map<std::string, std::map<unsigned int ,shared_ptr<const XdmfArrayType>(*)()> >
XdmfArrayType::mArrayDefinitions;
......@@ -154,7 +154,7 @@ XdmfArrayType::New(const std::map<std::string, std::string> & itemProperties)
// to support old xdmf defaults, return Float32()
return Float32();
}
const std::string & typeVal = ConvertToUpper(type->second);
const std::string typeVal = XdmfStringUtils::toUpper(type->second);
std::map<std::string, std::string>::const_iterator precision =
itemProperties.find("Precision");
const unsigned int precisionVal =
......
......@@ -24,9 +24,7 @@
#ifndef XDMFCORECONFIG_HPP_
#define XDMFCORECONFIG_HPP_
#cmakedefine HAVE_BOOST_SHARED_DYNAMIC_CAST
#cmakedefine XDMF_BIG_ENDIAN
#cmakedefine XDMF_NO_REALPATH
#endif /* XDMFCORECONFIG_HPP_ */
......@@ -28,7 +28,7 @@
#include "XdmfWriter.hpp"
#include <stack>
#include <cmath>
#include <boost/assign.hpp>
#include <string.h>
#include "XdmfError.hpp"
class XdmfFunctionInternalImpl : public XdmfFunction::XdmfFunctionInternal {
......@@ -93,14 +93,14 @@ const std::string XdmfFunction::mValidDigitChars = "1234567890.";
// The index of the corresponding operation in validOperationChars
// is the same as the index of its priority in this array
std::map<char, int> XdmfFunction::mOperationPriority =
boost::assign::map_list_of ('-', 4)
('+', 4)
('/', 3)
('*', 3)
('|', 2)
('#', 1)
('(', 0)
(')', 0);
{ {'-', 4},
{'+', 4},
{'/', 3},
{'*', 3},
{'|', 2},
{'#', 1},
{'{', 0},
{'}', 0} };
// The higher the value, the earlier the operation is
// evaluated in the order of operations
// With the exception of parenthesis which are evaluated
......@@ -109,46 +109,44 @@ std::map<char, int> XdmfFunction::mOperationPriority =
// Note, it doesn't handle overloaded functions well.
// Will generate errors unless overload methods are typecast.
std::map<std::string, shared_ptr<XdmfFunction::XdmfFunctionInternal> >
XdmfFunction::arrayFunctions =
boost::assign::map_list_of
("ABS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::abs))
("ABS_TOKEN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::abs))
("ACOS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arccos))
("ASIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arcsin))
("ATAN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arctan))
("AVE", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::average))
("COS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::cos))
("EXP", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::exponent))
("JOIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::join))
("LOG", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::log))
("SIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::sin))
("SQRT", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::sqrt))
("SUM", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::sum))
("TAN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::tan));
XdmfFunction::arrayFunctions =
{ {"ABS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::abs)},
{"ABS_TOKEN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::abs)},
{"ACOS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arccos)},
{"ASIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arcsin)},
{"ATAN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::arctan)},
{"AVE", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::average)},
{"COS", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::cos)},
{"EXP", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::exponent)},
{"JOIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::join)},
{"LOG", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::log)},
{"SIN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::sin)},
{"SQRT", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::sqrt)},
{"SUM", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::sum)},
{"TAN", XdmfFunctionInternalImpl::New((shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))
XdmfFunction::tan)} };
std::map<char, shared_ptr<XdmfFunction::XdmfOperationInternal> >
XdmfFunction::operations =
boost::assign::map_list_of
('-', XdmfOperationInternalImpl::New(XdmfFunction::subtraction))
('+', XdmfOperationInternalImpl::New(XdmfFunction::addition))
('*', XdmfOperationInternalImpl::New(XdmfFunction::multiplication))
('/', XdmfOperationInternalImpl::New(XdmfFunction::division))
('|', XdmfOperationInternalImpl::New(XdmfFunction::chunk))
('#', XdmfOperationInternalImpl::New(XdmfFunction::interlace));
XdmfFunction::operations = {
{'-', XdmfOperationInternalImpl::New(XdmfFunction::subtraction)},
{'+', XdmfOperationInternalImpl::New(XdmfFunction::addition)},
{'*', XdmfOperationInternalImpl::New(XdmfFunction::multiplication)},
{'/', XdmfOperationInternalImpl::New(XdmfFunction::division)},
{'|', XdmfOperationInternalImpl::New(XdmfFunction::chunk)},
{'#', XdmfOperationInternalImpl::New(XdmfFunction::interlace)} };
shared_ptr<XdmfFunction>
XdmfFunction::New()
......
......@@ -22,57 +22,6 @@
/*****************************************************************************/
#include "XdmfItemProperty.hpp"
#include <boost/assign.hpp>
const std::map<const char, const char> XdmfItemProperty::UpperConversionMap =
boost::assign::map_list_of ('a', 'A')
('b', 'B')
('c', 'C')
('d', 'D')
('e', 'E')
('f', 'F')
('g', 'G')
('h', 'H')
('i', 'I')
('j', 'J')
('k', 'K')
('l', 'L')
('m', 'M')
('n', 'N')
('o', 'O')
('p', 'P')
('q', 'Q')
('r', 'R')
('s', 'S')
('t', 'T')
('u', 'U')
('v', 'V')
('w', 'W')
('x', 'X')
('y', 'Y')
('z', 'Z');
// Using this method because ANSI and std transform aren't guarenteed
std::string
XdmfItemProperty::ConvertToUpper(const std::string & converted)
{
std::string returnstring;
returnstring.resize(converted.size());
std::map<const char, const char>::const_iterator characterConversion;
for (unsigned int i = 0; i < converted.size(); ++i)
{
characterConversion = UpperConversionMap.find(converted[i]);
if (characterConversion != UpperConversionMap.end())
{
returnstring[i] = characterConversion->second;
}
else
{
returnstring[i] = converted[i];
}
}
return returnstring;
}
XdmfItemProperty::XdmfItemProperty()
{
......
......@@ -76,10 +76,6 @@ protected:
XdmfItemProperty();
static std::string ConvertToUpper(const std::string & converted);
static const std::map<const char, const char> UpperConversionMap;
private:
XdmfItemProperty(const XdmfItemProperty &); // Not implemented.
......
......@@ -39,8 +39,6 @@ shared_ptr<T> shared_dynamic_cast(shared_ptr<U> const & r)
return std::dynamic_pointer_cast<T>(r);
}
//#endif /* HAVE_BOOST_SHARED_DYNAMIC_CAST */
#endif
#endif /* XDMFSHAREDPTR_HPP_ */
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfStringUtils.cpp */
/* */
/* Author: */
/* Kenneth Leiter */
/* kenneth.leiter@arl.army.mil */
/* US Army Research Laboratory */
/* Aberdeen Proving Ground, MD */
/* */
/* Copyright @ 2011 US Army Research Laboratory */
/* All Rights Reserved */
/* See Copyright.txt for details */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*****************************************************************************/
#include <cctype>
#include "XdmfStringUtils.hpp"
XdmfStringUtils::XdmfStringUtils()
{
}
XdmfStringUtils::~XdmfStringUtils()
{
}
std::string
XdmfStringUtils::toUpper(const std::string & string)
{
std::string returnString;
std::transform(string.begin(),
string.end(),
std::back_inserter(returnString),
[](unsigned char c) {return std::toupper(c); } );
return returnString;
}
......@@ -31,6 +31,7 @@
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>
/**
......@@ -43,7 +44,7 @@ class XDMFCORE_EXPORT XdmfStringUtils {
public:
/**
* Split a string by whitespace and insert into container
* Split a string by whitespace and insert into container.
*
* @param stringToSplit a string to split by spaces.
* @param containerToInsert a container to insert the split string into.
......@@ -52,6 +53,15 @@ class XDMFCORE_EXPORT XdmfStringUtils {
static void split(const std::string & stringToSplit,
std::vector<T> & containerToInsert);
/**
* Capitalize a string.
*
* @param string to capitalize
*
* @return capitalized string
*/
static std::string toUpper(const std::string & string);
protected:
XdmfStringUtils();
......
......@@ -45,5 +45,11 @@ int main() {
assert(split[1] == 2);
assert(split[2] == 3);
const std::string abc("abc");
const std::string capABC = XdmfStringUtils::toUpper(abc);
assert(abc.compare("abc") == 0);
assert(capABC.compare("ABC") == 0);
return 0;
}
#include <cstring>
#include <iostream>
#include <stack>
#include <map>
......@@ -8,7 +9,6 @@
#include <XdmfArray.hpp>
#include <XdmfArrayType.hpp>
#include <XdmfFunction.hpp>
#include "boost/assign.hpp"
double parse(std::string expression, std::map<std::string, double> variables);
double calculation(double val1, double val2, char operation);
......@@ -27,12 +27,11 @@ shared_ptr<XdmfArray> maximum(std::vector<shared_ptr<XdmfArray> > values);
std::string validDigitChars = "-1234567890.";
std::string validVariableChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_:.";
//std::map<std::string, double (*)(std::vector<double>)> functions = boost::assign::map_list_of ("SUM", sum) ("AVE", ave);
std::map<std::string, double (*)(std::vector<double>)> functions = boost::assign::map_list_of ("SUM", (double (*)(std::vector<double>))sum);
std::map<std::string, double (*)(std::vector<double>)> functions =
{ {"SUM", (double (*)(std::vector<double>))sum} };
//note, it doesn't handle overloaded functions well. Will generate errors unless typecast
//std::map<std::string, double (*)(std::vector<double>)> functions = boost::assign::map_list_of ("SUM", sum) ("AVE", ave);
std::map<std::string, shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >)> arrayFunctions = boost::assign::map_list_of ("SUM", (shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))sum) ("MAX", (shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))maximum);
std::map<std::string, shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >)> arrayFunctions = { {"SUM", (shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))sum}, {"MAX", (shared_ptr<XdmfArray> (*)(std::vector<shared_ptr<XdmfArray> >))maximum} };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment