From 40ad5303c7e3522f6f40d95ec56e4a9f1aa1dd72 Mon Sep 17 00:00:00 2001 From: kanschat Date: Mon, 20 Sep 2010 16:52:02 +0000 Subject: [PATCH] add function to generate a base name usefull to determine the regression test directory git-svn-id: https://svn.dealii.org/trunk@22087 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/job_identifier.h | 16 +++++++++++++++- deal.II/base/source/job_identifier.cc | 17 ++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/deal.II/base/include/base/job_identifier.h b/deal.II/base/include/base/job_identifier.h index abb7fb3761..1a37b4b78e 100644 --- a/deal.II/base/include/base/job_identifier.h +++ b/deal.II/base/include/base/job_identifier.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -55,6 +55,20 @@ class JobIdentifier */ static const char* program_id(); + /** + * Obtain the base name of the + * file currently being + * compiled. That is, if the file + * is mypath/file.cc + * return just + * file. Typically, this + * can be called from a program + * with the argument + * __FILE__ and is uded + * in the deal.II test suite. + */ + static std::string base_name(const char* filename); + /** * Return the value of id. */ diff --git a/deal.II/base/source/job_identifier.cc b/deal.II/base/source/job_identifier.cc index 371eaa3916..98e1152a69 100644 --- a/deal.II/base/source/job_identifier.cc +++ b/deal.II/base/source/job_identifier.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2009 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -48,4 +48,19 @@ JobIdentifier::operator ()() const return id; } + +std::string +JobIdentifier::base_name(const char* filename) +{ + std::string name(filename); + std::string::size_type pos = name.find("."); + name.erase(pos, name.size()); + pos = name.rfind("/"); + if (pos < name.size()) + name.erase(0,pos); + return name; +} + + + DEAL_II_NAMESPACE_CLOSE -- 2.39.5