You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by pa...@apache.org on 2001/02/13 18:09:50 UTC
cvs commit: xml-xalan/c/Tests/Harness FileUtility.cpp FileUtility.hpp
pauldick 01/02/13 09:09:50
Added: c/Tests/Harness FileUtility.cpp FileUtility.hpp
Log:
Utility used to accesses all the test files
Revision Changes Path
1.1 xml-xalan/c/Tests/Harness/FileUtility.cpp
Index: FileUtility.cpp
===================================================================
/*
*
* FileUtility.cpp
*
* Copyright 2000 Lotus Development Corporation. All rights reserved.
* This software is subject to the Lotus Software Agreement, Restricted
* Rights for U.S. government users and applicable export regulations.
*/
#include <stdlib.h>
#include <cstdio>
#include <ctime>
#include <vector>
#if defined(XALAN_OLD_STREAM_HEADERS)
#include <iostream.h>
#else
#include <iostream>
#endif
#if !defined(NDEBUG) && defined(_MSC_VER)
#include <crtdbg.h>
#endif
//#include <Include/PlatformDefinitions.hpp>
#include <framework/URLInputSource.hpp>
#include <util/PlatformUtils.hpp>
#include <XalanDOM/XalanNode.hpp>
#include <XalanDOM/XalanDocument.hpp>
#include <XalanDOM/XalanElement.hpp>
#include <XalanDOM/XalanNodeList.hpp>
#include <PlatformSupport/DoubleSupport.hpp>
#include <PlatformSupport/DirectoryEnumerator.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/XalanUnicode.hpp>
#include <PlatformSupport/XalanOutputStreamPrintWriter.hpp>
#include <PlatformSupport/XalanStdOutputStream.hpp>
#include "FileUtility.hpp"
#if defined(XALAN_NO_NAMESPACES)
typedef vector<XalanDOMString> FileNameVectorType;
#else
typedef std::vector<XalanDOMString> FileNameVectorType;
#endif
/* This routine retrieves test file names from specified directories.
// Inputs: baseDir: typically "conf" or "perf"
// relDir: sub-directory to search.
//
// Notes: It builds the searchSpecification by concatenating all the
// necessary components.
// */
FileNameVectorType FileUtility::getTestFileNames(XalanDOMString baseDir, XalanDOMString relDir)
{
const XalanDOMString pathSep(XALAN_STATIC_UCODE_STRING("\\"));
const XalanDOMString searchSuffix(XALAN_STATIC_UCODE_STRING("*.xml"));
const XalanDOMString searchSpecification(baseDir + relDir + pathSep + relDir + searchSuffix);
DirectoryEnumeratorFunctor<FileNameVectorType, XalanDOMString> theEnumerator;
FileNameVectorType theFiles;
theEnumerator(searchSpecification, theFiles);
return theFiles;
}
/* This routine retrieves all sub-directories from the specified directories.
// Inputs: rootDirectory: typically "conf" or "perf"
//
// Notes: The searchSpecification in this case is just "*".
// */
FileNameVectorType FileUtility::getDirectoryNames(XalanDOMString rootDirectory)
{
const XalanDOMString dirSpec(XALAN_STATIC_UCODE_STRING("*"));
DirectoryEnumeratorFunctor<FileNameVectorType, XalanDOMString, DirectoryFilterPredicate> theEnumerator;
FileNameVectorType theFiles;
theEnumerator(XalanDOMString(rootDirectory), XalanDOMString(dirSpec), theFiles);
return theFiles;
}
/* This routine generates file names based on the provide suffix
// Inputs: theXMLFileName: typically "conf" or "perf"
// suffix: typically "xsl" or "out".
//
// Notes:
// */
XalanDOMString FileUtility::GenerateFileName(const XalanDOMString& theXMLFileName, char* suffix)
{
XalanDOMString theResult;
int thePeriodIndex = -1;
const int theLength = length(theXMLFileName);
for (int i = theLength - 1; i > 0; i--)
{
if (charAt(theXMLFileName, i) == XalanUnicode::charFullStop)
{
thePeriodIndex = i; // charFullStop is the dot (x2E)
break;
}
}
if (thePeriodIndex != -1)
{
theResult = substring(theXMLFileName,
0,
thePeriodIndex + 1);
theResult += XalanDOMString(suffix);
}
return theResult;
}
1.1 xml-xalan/c/Tests/Harness/FileUtility.hpp
Index: FileUtility.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* FileUtility.hpp
*/
#if !defined(FILEUTILITY_HEADER_GUARD_1357924680)
#define FILEUTILITY_HEADER_GUARD_1357924680
#include<string>
#include<stdio.h>
#include <time.h>
using namespace std;
/**
* Utility call that extracts test file names from testsuite.
* @author Paul Dick@lotus.com
* @version $Id: FileUtility.hpp,v 1.1 2001/02/13 17:09:49 pauldick Exp $
*/
#if defined HARNESS_EXPORTS
#define HARNESS_API __declspec(dllexport)
#else
#define HARNESS_API __declspec(dllimport)
#endif
#if defined(XALAN_NO_NAMESPACES)
typedef vector<XalanDOMString> FileNameVectorType;
#else
typedef std::vector<XalanDOMString> FileNameVectorType;
#endif
// This class is exported from the Harness.dll
class HARNESS_API FileUtility
{
public:
/** Simple constructor, does not perform initialization. */
FileUtility()
{
}
/**
* Utility method used to get test files from a specific directory.
* @returns a vector containing test files.
*/
FileNameVectorType getTestFileNames(XalanDOMString baseDir, XalanDOMString relDir);
//FileNameVectorType getTestFileNames (char* theDirectory);
/**
* Utility method used to get subdirectories from a specific directory.
* @returns a vector containing directory files.
*/
FileNameVectorType getDirectoryNames(XalanDOMString rootDirectory);
/**
* Utility method used to get XSL file based on XML file.
* @returns a XalanDOMString.
*/
XalanDOMString GetXSLFileName(const XalanDOMString& theXMLFileName);
/**
* Utility method used to get OUT file based on XML file.
* @returns a XalanDOMString.
*/
XalanDOMString FileUtility::GenerateFileName(const XalanDOMString& theXMLFileName, char* suffix);
}; // end of class FileUtility
#endif