-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplified CMake options, use target_link_dependencies(), target_incl…
…ude_directories(), some libs installed on Vagrant build machines (see Build.txt). Builds all solvers (except Chombo and Hy3S) on Linux64-client, Linux64-server, Win64. svn path=/vcell/trunk/numerics/; revision=21109 Former-commit-id: 74137fd147f6351f78ac0ada7b33b14678c597f8
- Loading branch information
Showing
9 changed files
with
4,492 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
project(vcommons) | ||
|
||
file(GLOB SRC_FILES src/*cpp) | ||
|
||
file(GLOB HEADER_FILES include/*h include/*hpp) | ||
include_directories(${PROJECT_SOURCE_DIR}/include) | ||
|
||
include_directories(include) | ||
set_source_files_properties( ${SRC_FILES} PROPERTIES LANGUAGE CXX) | ||
add_library(vcommons ${SRC_FILES} ${HEADER_FILES}) | ||
target_include_directories(vcommons PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> # <prefix>/include | ||
) | ||
|
||
install(TARGETS vcommons ARCHIVE DESTINATION lib) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#ifndef OstreamSpy_h | ||
#define OstreamSpy_h | ||
#include <streambuf> | ||
namespace vcell_util { | ||
|
||
/** | ||
* specialized streambuf for uses in OStreamSpy | ||
* @tparam Spy class which implements intercept(char_type) | ||
*/ | ||
template <class Spy, typename char_type, typename traits = std::char_traits<char_type> > | ||
struct Spybuf: public std::basic_streambuf<char_type, traits> { | ||
// based on public domain code by Thomas Guest | ||
// http://wordaligned.org/articles/cpp-streambufs | ||
|
||
typedef typename traits::int_type int_type; | ||
|
||
/** | ||
@param spy_ -- reference must remain valid | ||
@param sb streambuf to spy upon | ||
*/ | ||
Spybuf(Spy & spy_,std::basic_streambuf<char_type, traits> * sb) | ||
:spy(spy_), | ||
realbuf(sb) | ||
{ | ||
} | ||
|
||
private: | ||
virtual int sync() | ||
{ | ||
return realbuf->pubsync( ); | ||
} | ||
|
||
virtual int_type overflow(int_type c) | ||
{ | ||
int_type const eof = traits::eof(); | ||
|
||
if (traits::eq_int_type(c, eof)) | ||
{ | ||
return traits::not_eof(c); | ||
} | ||
else | ||
{ | ||
char_type const ch = traits::to_char_type(c); | ||
spy.intercept(ch); | ||
return realbuf->sputc(ch); | ||
} | ||
} | ||
|
||
private: | ||
Spy & spy; | ||
std::basic_streambuf<char_type, traits> * realbuf; | ||
}; | ||
|
||
/** | ||
* class to intercept writes to an existing ostream | ||
* @tparam Spy class which implements intercept(char_type) | ||
*/ | ||
template <class Spy, typename char_type = char, typename traits = std::char_traits<char_type> > | ||
struct OStreamSpy { | ||
/** | ||
@param target stream to intercept | ||
@param spy -- reference must remain valid | ||
*/ | ||
OStreamSpy( std::basic_ostream<char_type,traits> & target_, Spy & spy_ ) | ||
:target(target_), | ||
spy(spy_), | ||
targetbuf(target_.rdbuf( )), | ||
spybuf(spy_,targetbuf) | ||
{ | ||
target.rdbuf(&spybuf); | ||
} | ||
/** | ||
* restores previous streambuf | ||
*/ | ||
~OStreamSpy( ) { | ||
target.rdbuf(targetbuf); | ||
} | ||
private: | ||
std::basic_ostream<char_type,traits> & target; | ||
Spy & spy; | ||
std::basic_streambuf<char,traits> * targetbuf; | ||
// must come after targetbuf in class declaration due to initialization order | ||
Spybuf<Spy, char_type, traits> spybuf; | ||
}; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef VCellException_h | ||
#define VCellException_h | ||
#include <sstream> | ||
#include <stdexcept> | ||
|
||
/** | ||
* based on some ideas in apache Log4jcxxx (BSD licensed) | ||
* @param EXC std:: exception to throw | ||
* @param x code fragment to stream | ||
*/ | ||
#define VCELL_RUNTIME_EXCEPTION(x) { std::ostringstream oss; oss << x << " at " << __FILE__ << ':' << __LINE__ << std::ends; throw std::runtime_error(oss.str( )); } | ||
#define VCELL_EXCEPTION(EXC,x) { std::ostringstream oss; oss << x << " at " << __FILE__ << ':' << __LINE__ << std::ends; throw std::EXC(oss.str( )); } | ||
#define VCELL_EXCEPTION_NOLOCATION(EXC,x) { std::ostringstream oss; oss << x << std::ends; throw std::EXC(oss.str( )); } | ||
#endif |
Oops, something went wrong.