exceptiondir = $(includedir)
nobase_exception_HEADERS = \
glite/wmsutils/exception/exception_codes.h \
- glite/wmsutils/exception/Exceptions.h \
- glite/wmsutils/exception/result_codes.h
+ glite/wmsutils/exception/Exception.h
MAINTAINERCLEANFILES = Makefile.in
--- /dev/null
+#ifndef GLITE_WMS_UTILS_EXCEPTION_EXCEPTION_H
+#define GLITE_WMS_UTILS_EXCEPTION_EXCEPTION_H
+
+/*
+ * Exception.h
+ * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved.
+ * Contributors are mentioned in the code where appropriate.
+ */
+
+#include <fstream>
+#include <cstdlib>
+//#include <list>
+#include <syslog.h> // For logging exceptions to log file
+#include <errno.h> // list the exception codes
+#include <string>
+#include <exception> // base ancestor stl::exception
+
+
+namespace glite {
+ namespace wmsutils {
+ namespace exception {
+
+extern pthread_mutex_t METHOD_MUTEX; // used in order to store info into a file (rather then syslog)
+#define GLITE_STACK_TRY(method_name) std::string METHOD = method_name ; try {
+#define GLITE_STACK_CATCH() } catch (glite::wmsutils::exception::Exception &exc){ throw glite::wmsutils::exception::Exception ( __FILE__ , METHOD , &exc) ; }
+
+/**
+ * The Exception base classe contains attributes into which are placed exception information and provides
+ * constructor that beyond the error code take parameters specifying the source file and line number
+ * (e.g. through __FILE__ and __LINE__) where the error has been generated and string messages,
+ * allowing an easy way of storing the origin of the exception.
+ * Moreover it provides methods for getting all the exception information and for logging them either
+ * in a log file or to the syslog daemon.
+ * Each of the derived types may contain its private attributes describing the actual error instance in detail.
+ * Moreover each exception has an attribute representing the exception identifier that is set by the
+ * class constructor and allows the identification of the original exception.
+ *
+ * @version 0.1
+ * @date 22 July 2004
+ * @author Alessandro Maraschini <alessandro.maraschini@datamat.it>
+*/
+
+class Exception : public std::exception{
+ public:
+ /**
+ * Constructor Update all mandatory fields
+ * @param method the name of the method that raised the exception
+ * @param source The source that raised the exception (could be the file path, the class Name, etc etc)
+ * @param exc the previous exception as in the stack trace */
+ Exception ( const std::string& source, const std::string& method, Exception *exc);
+ /**
+ * Constructor Update all mandatory fields
+ * @param code the code representing the thrown exception
+ * @param exception the name of the thrown exception
+ * @param method the name of the method that raised the exception
+ * @param source The source that raised the exception (could be the file path, the class Name, etc etc)
+ * @param line_number the number of the line in the file that raised the exception(if the source has been given as a file) */
+ Exception ( const std::string& source, const std::string& method, int code, const std::string& exception);
+
+ /**
+ * Constructor Update all mandatory fields
+ * @param source the path of the file that raised the exception
+ * @param line_number the number of the line in the file that raised the exception
+ * @param method the name of the method that raised the exception
+ * @param code the code representing the thrown exception
+ * @param exception the name of the thrown exception */
+ Exception (const std::string& source, int line_number, const std::string& method, int code, const std::string& exception);
+ /**
+ * Default Destructor
+ */
+ virtual ~Exception() throw ();
+ /**
+ * Return a string debug message containing information about Exception thrown
+ * Debug message contains all the attributes stored in an exception instance such as the method, the file and the line
+ * that threw the exception.
+ *@return the debug message string representation
+ */
+ virtual std::string dbgMessage();
+ /**
+ * Return the error code
+ * @return The integer representing the code of the error that generated the exception
+ */
+ virtual int getCode();
+
+ /**
+ * return the Error Message associated to the Exception
+ * @return The Exception string message representation
+ */
+ virtual const char* what() const throw ();
+
+ /**
+ * Print Exception error information into a log file
+ * @param logfile the file where to log exception information
+ */
+ virtual void log(const std::string& logfile = "");
+ /**
+ * Retrieve the Exception name
+ * @return the name of the Exception thrown
+ */
+ virtual std::string getExceptionName();
+
+ /**
+ * Retrieve the Stack of the exception as a list of previous generated exceptions
+ *@return the string representation of the stack trace: each line correspond to an exception message
+ */
+ virtual std::string printStackTrace() ;
+
+ protected:
+ Exception();
+ int error_code;
+ std::string error_message ;
+ int line;
+ std::string source_file;
+ std::string exception_name;
+ std::string method_name ;
+ std::string stack;
+ std::string ancestor ;
+}; //End Exception Class
+}}} // Closing namespace
+#endif
+++ /dev/null
-#ifndef GLITE_WMSUTILS_EXCEPTION_EXCEPTIONS_H
-#define GLITE_WMSUTILS_EXCEPTION_EXCEPTIONS_H
-
-/*
- * Exceptions.h
- * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved.
- * Contributors are mentioned in the code where appropriate.
- */
-
-#include <fstream>
-#include <cstdlib>
-//#include <list>
-#include <syslog.h> // For logging exceptions to log file
-#include <errno.h> // list the exception codes
-#include <string>
-#include <exception> // base ancestor
-
-#include "glite/wmsutils/exception/result_codes.h" //base result codes
-
-namespace glite {
-namespace wmsutils {
-namespace exception {
-
-extern pthread_mutex_t METHOD_MUTEX; // used in order to store info into a file (rather then syslog)
-#define EDG_STACK_TRY(method_name) std::string METHOD = method_name ; try {
-#define EDG_STACK_CATCH() } catch (glite::wms::common::utilities::Exception &exc){ throw glite::wms::common::utilities::Exception ( __FILE__ , METHOD , &exc) ; }
-
-/**
- * The Exception classes contains attributes into which are placed exception information and provides
- * constructors that beyond the error code take parameters specifying the source file and line number
- * (e.g. through __FILE__ and __LINE__) where the error has been generated and string messages,
- * allowing an easy way of storing the origin of the exception.
- * Moreover it provides methods for getting all the exception information and for logging them either
- * in a log file or to the syslog daemon.
- * Each of the derived types may contain its private attributes describing the actual error instance in detail.
- * For example a JdlSyntaxException thrown when parsing the job description could contain additional
- * details indicating exactly on which attributes the error occurred.
- * Moreover each exception has an attribute representing the exception identifier that is set by the
- * class constructor and allows the identification of the original exception.
- *
- * @ingroup Common
- * @version 0.1
- * @date 15 April 2002
- * @author Alessandro Maraschini <alessandro.maraschini@datamat.it>
-*/
-
-class Exception : public std::exception{
- public:
- Exception ( const std::string& source,
- const std::string& method,
- Exception *e);
- /**
- * Constructor Update all mandatory fields
- * @param code the code representing the thrown exception
- * @param exception the name of the thrown exception
- * @param method the name of the method that raised the exception
- * @param source The source that raised the exception (could be the file path, the class Name, etc etc)
- * @param line_number the number of the line in the file that raised the exception(if the source has been given as a file) */
-
- Exception ( const std::string& source,
- const std::string& method,
- int code,
- const std::string& exception);
-
- /**
- * Constructor Update all mandatory fields
- * @param source the path of the file that raised the exception
- * @param line_number the number of the line in the file that raised the exception
- * @param method the name of the method that raised the exception
- * @param code the code representing the thrown exception
- * @param exception the name of the thrown exception */
- Exception (const std::string& source,
- int line_number,
- const std::string& method,
- int code,
- const std::string& exception);
-
- /**
- * Destructor
- */
- virtual ~Exception() throw ();
- /**
- * Return a string debug message containing information about Exception thrown
- */
- virtual std::string dbgMessage();
- /**
- * Return the Code number
- */
- virtual int getCode();
-
- /**
- * return the Error Message associated to the Exception
- */
- virtual const char* what() const throw ();
-
- /**
- * Print Exception error information into a log file
- */
- virtual void log(const std::string& logfile = "");
- /**
- * Return the name of the Exception raised
- */
- virtual std::string getExceptionName();
-
- /**
- * Return the list of methods that caused the Exception
- */
- virtual std::string printStackTrace() ;
-
- protected:
- /**
- * Empty Default Constructor
- */
- Exception();
- //Mandatory Information:
- int error_code;
- std::string error_message ;
- int line;
- std::string source_file;
- std::string exception_name;
- std::string method_name ;
- std::string stack;
- std::string ancestor ;
- // Exception* exc ;
-}; //End Exception Class
-
-/**
- * This Exception is thrown when a unespected fatal error is found
- */
-class FatalErrorException : public Exception {
-public:
- FatalErrorException(const std::string& file,
- int line,
- const std::string& method);
-};//End CLass FatalErrorException
-
-/**
- * StdException remap the Exception thrown by std::exception class into the JSUI WL standard format
- */
-class StdException : public Exception {
-public:
- StdException(const std::string& file,
- int line,
- const std::string& method,
- int code,
- const std::string& exception_name);
-};//End CLass StdException
-
-/**
- * StdException remap the Exception thrown by std::exception class into the JSUI WL standard format
- */
-class ThreadException : public Exception {
-public:
- ThreadException(const std::string& file,
- int line,
- const std::string& method,
- int code,
- int jobNumber);
-};//End CLass StdException
-
-} // exception namespace
-} // wmsutils namespace
-} // glite namespace
-
-#endif
-#ifndef GLITE_WMSUTILS_EXCEPTION_CODES_H
-#define GLITE_WMSUTILS_EXCEPTION_CODES_H
-
-// pure C-style code:
+#ifndef GLITE_WMSUTILS_EXCEPTION_CODES_H
+#define GLITE_WMSUTILS_EXCEPTION_CODES_H
+// pure C-style code (needed by some libraries)
#define GLITE_WMS_COMMON_ERROR_BASE 900
#define GLITE_WMS_USERINTERFACE_ERROR_BASE 1000
#define GLITE_WMS_NETWORKSERVER_ERROR_BASE 1200
#define GLITE_WMS_REQUESTAD_ERROR_BASE 1500
#define GLITE_WMS_CHECKPOINT_ERROR_BASE 1600
#define GLITE_WMS_CONFIGURATION_ERROR_BASE 1800
-
#ifdef __cplusplus
-
-namespace glite {
-namespace wmsutils {
+namespace glite {
+namespace wmsutils {
namespace exception {
-
-/**
- * The Error Code
-*/
-enum {
- WMS_COMMON_BASE = GLITE_WMS_COMMON_ERROR_BASE,
- THREAD_INIT , // pthread_attr_init method failed
- THREAD_DETACH , // pthread_attr_setdetachstate method failed
- THREAD_CREATE , // pthread_create method failed
- THREAD_JOIN,
- THREAD_SSL,
- WMS_FATAL_ERROR,
- WMS_UI_ERROR_BASE = GLITE_WMS_USERINTERFACE_ERROR_BASE,
- WMS_NS_ERROR_BASE = GLITE_WMS_NETWORKSERVER_ERROR_BASE,
- WMS_SOCKET_ERROR_BASE = GLITE_WMS_SOCKET_ERROR_BASE,
- WMS_LDAP_ERROR_BASE = GLITE_WMS_LDAP_ERROR_BASE,
- WMS_LB_ERROR_BASE = GLITE_WMS_LOGGING_ERROR_BASE ,
- WMS_REQUESTAD_ERROR_BASE = GLITE_WMS_REQUESTAD_ERROR_BASE,
- WMS_CHKPT_ERROR_BASE = GLITE_WMS_CHECKPOINT_ERROR_BASE,
- WMS_CONFIGURATION_ERROR_BASE = GLITE_WMS_CONFIGURATION_ERROR_BASE
-};
-
+ /**
+ * The Error Code
+ */
+ enum {
+ WMS_COMMON_BASE = GLITE_WMS_COMMON_ERROR_BASE,
+ WMS_THREAD_INIT , // pthread_attr_init method failed
+ WMS_THREAD_DETACH , // pthread_attr_setdetachstate method failed
+ WMS_THREAD_CREATE , // pthread_create method failed
+ WMS_THREAD_JOIN,
+ WMS_THREAD_SSL,
+ WMS_FATAL_ERROR,
+ WMS_UI_ERROR_BASE = GLITE_WMS_USERINTERFACE_ERROR_BASE,
+ WMS_NS_ERROR_BASE = GLITE_WMS_NETWORKSERVER_ERROR_BASE,
+ WMS_SOCKET_ERROR_BASE = GLITE_WMS_SOCKET_ERROR_BASE,
+ WMS_LDAP_ERROR_BASE = GLITE_WMS_LDAP_ERROR_BASE,
+ WMS_LB_ERROR_BASE = GLITE_WMS_LOGGING_ERROR_BASE ,
+ WMS_REQUESTAD_ERROR_BASE = GLITE_WMS_REQUESTAD_ERROR_BASE,
+ WMS_CHKPT_ERROR_BASE = GLITE_WMS_CHECKPOINT_ERROR_BASE,
+ WMS_CONFIGURATION_ERROR_BASE = GLITE_WMS_CONFIGURATION_ERROR_BASE
+ };
} // exception namespace
} // wmsutils namespace
} // glite namespace
-
#endif //ifdef c++
#endif
+++ /dev/null
-#ifndef GLITE_WMSUTILS_EXCEPTION_RESULT_CODES_H
-#define GLITE_WMSUTILS_EXCEPTION_RESULT_CODES_H
-
-namespace glite {
-namespace wmsutils {
-namespace exception {
-/*
- * exception_codes.h
- * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved.
- * Contributors are mentioned in the code where appropriate.
- */
-
-
-/**
- * Result Code
-*/
-enum ResultCode {
- SUCCESS, // The requested operation has been completed successfully
- ACCEPTED, // The requested operation has been accepted
-
- SUBMISSION_FAILURE, // API failed, general RB Exc remapping
- CANCEL_FAILURE, // API failed, general RB Exc remapping
- GETOUTPUT_FAILURE, // API failed, general RB Exc remapping
- STATUS_FAILURE, // API failed, general RB Exc remapping
-
- GETOUTPUT_FORBIDDEN, //When trying to retrieve output from a not submitted job
- CANCEL_FORBIDDEN, //When trying to cancel a not submitted job
- STATUS_FORBIDDEN, //When trying to retrieve status from a not submitted job
- ALREADY_SUBMITTED, //submit skipped because Job has been already submitted
-
- JOIN_FAILED, //When a pthread_join is waiting for a cored thread
-
- OUTPUT_NOT_READY, //JobNotDoneException
- FILE_TRANSFER_ERROR, //SandboxIOException
- JOB_NOT_FOUND, //JobNotFoundException
-
- MARKED_FOR_REMOVAL, //Cancel Method Result
- GENERIC_FAILURE, //Cancel Method Result
- CONDOR_FAILURE, //Cancel Method Result
-
- GLOBUS_JOBMANAGER_FAILURE,
-
- JOB_ALREADY_DONE,
- JOB_ABORTED,
- JOB_CANCELLING,
- JOB_NOT_OWNER
-
-};
-
-} // exception namespace
-} // wmsutils namespace
-} // glite namespace
-
-#endif
+++ /dev/null
-/* **************************************************************************
-* filename : Exceptions.cpp
-* author : Alessandro Maraschini <alessandro.maraschini@datamat.it>
-* copyright : (C) 2002 by DATAMAT
-***************************************************************************/
-
-#include "glite/wmsutils/exception/Exceptions.h"
-#include "glite/wmsutils/exception/exception_codes.h"
-#include "utils.h"
-
-namespace glite {
-namespace wmsutils {
-namespace exception {
-
-using namespace std ;
-using namespace glite::wmsutils::exception ;
-
-pthread_mutex_t METHOD_MUTEX ; // This mutex is used in order to lock the file for writing log infornation
-/* *********************************
-* Exception Class Implementation
-************************************/
-//Constructor/Destructor
-
-Exception::Exception () {
- //exc = NULL ;
- stack= "";
- line = 0;
-} ;
-
-Exception::~Exception() throw(){ }
-/**
-* Exception chainig
-*/
-Exception::Exception ( const string& source,
- const string& method,
- Exception *e){
- source_file = source ;
- method_name = method;
- error_message = "";
- stack= e->printStackTrace();
- ancestor = e->what() ;
- line = 0;
- error_code= 0;
-};
-Exception::Exception( const std::string& file,
- int line_number,
- const std::string& method,
- int code,
- const std::string& name)
- : error_code(code), exception_name(name){
- source_file = file;
- line = line_number;
- method_name = method;
- stack= "";
-};
-Exception::Exception (const string& source,
- const string& method,
- int code,
- const string& exception)
- : error_code(code), exception_name(exception){
- source_file = source;
- method_name = method;
- stack= "";
- line = 0;
-};
-int Exception::getCode(){
- if (error_code != 0)
- return error_code ;
- else
- return WMS_COMMON_BASE;
-};
-const char* Exception::what() const throw(){
- if (!ancestor.empty() )
- return ancestor.c_str() ;
- if ( error_message != "")
- return error_message.c_str() ;
- else
- return "" ;
-
-};
-string Exception::getExceptionName(){
- if (exception_name!= "")
- return exception_name;
- else
- return "" ;
-};
-void Exception::log(const std::string& logfile)
-{
- if ( logfile == "")
- syslog ( LOG_PERROR, (char *) (dbgMessage()).c_str() );
- else{
- pthread_mutex_lock( &METHOD_MUTEX); // LOCK
- //TBD : test if file exist-->>Create HEADER ??
- ofstream fout ((char *) logfile.c_str() , ios::app ); //Open the file for writing (if it doesn't exist then it will be created)
- fout << "\n" << dbgMessage() ; //write (append) the message
- fout.close(); //close the file
- pthread_mutex_unlock( &METHOD_MUTEX); // UNLOCK
- }
-};
-string Exception::printStackTrace(){
-return stack + "\n" + dbgMessage();
-};
-string Exception::dbgMessage(){
- // cout << "\nDBM callded for :" << this;
- string result ;
- //Adding exception Name
- if ( exception_name!="")
- result = exception_name ;
- //Adding error msg
- if (error_message!="")
- result +=": " + string(what());
- if (result != "")
- result+="\n";
- //Adding Source
- result +=" at " + source_file ;
- //Adding line number
- if (line!=0)
- result += " Line: " + inTo(line);
- result +=" " ;
- //Adding Method Name
- if (method_name != "")
- result += "Method: " +method_name ;
- return result;
-}
-FatalErrorException::FatalErrorException(const std::string& file,
- int line,
- const std::string& method)
- : Exception(file, line, method, WMS_FATAL_ERROR, "FatalErrorException")
-{
- error_message = "Fatal Error found: system is unable to continue";
-}
-StdException::StdException(const std::string& file,
- int line,
- const std::string& method,
- int code,
- const std::string& exception_name)
- : Exception(file, line, method, code, "StdException")
-{
- error_message = "std::exception Fatal Error thrown: " + exception_name;
-}
-ThreadException::ThreadException(const std::string& file,
- int line,
- const std::string& method,
- int code,
- int jobNumber)
- : Exception(file, line, method, code, "ThreadException")
-{
-
- switch (code){
- case THREAD_INIT:
- error_message = "pthread_attr_init";
- break;
- case THREAD_DETACH :
- error_message = "pthread_attr_setdetachstate";
- break;
- case THREAD_SSL :
- error_message = "SSL multi thread procedure";
- break;
- case THREAD_CREATE :
- error_message = "pthread_create";
- break;
- default: //THREAD_JOIN
- error_message = "pthread_join";
- break;
- }
- error_message += "pthread Fatal Error thrown for: " + error_message ;
-}
-
-} // exception namespace
-} // wmsutils namespace
-} // glite namespace
## *
## *********************************************************************
-lib_LTLIBRARIES = libglite_wmsutils_exceptions.la
+lib_LTLIBRARIES = libglite_wmsutils_exception.la
-libglite_wmsutils_exceptions_la_SOURCES = \
- Exceptions.cpp \
- utils.cpp
+libglite_wmsutils_exception_la_SOURCES = \
+ Exception.cpp
utilitiesincludedir = $(includedir)/glite/wmsutils/exception
utilitiesinclude_HEADERS = \
+++ /dev/null
-/* **************************************************************************
-* filename : utils.cpp
-* author : Alessandro Maraschini <alessandro.maraschini@datamat.it>
-* copyright : (C) 2002 by DATAMAT
-***************************************************************************/
-#include "utils.h"
-#include <string>
-#include <stdio.h>
-
-using namespace std;
-
-namespace glite {
-namespace wmsutils {
-namespace exception {
-
-/******************************************************************
- method : isInt
- field: integer & string class
- check if str is an integer
-*******************************************************************/
-int isInt (const string& str)
-{
- int len, bCode,eCode;
- char code ;
- const char * strCh ;
- len = str.size() ;
- strCh = str.c_str();
- bCode= '0';
- eCode= '9';
- for (int i=0; i<len; i++){
- code=strCh[i];
- if ( (code < bCode) || (code >eCode) ) //It's not a digit number
- return 1;
- }
- return 0;
-}
-
-
-/******************************************************************
- methods : toInt , toHex
- field: integer & string class
- Converts a string str to an Integer value sum
- returns 0/1 ---> success/failure
- STRING--->INTEGER
-*******************************************************************/
-int toHex (const string& str,int &sum)
-{
- int len, bCode,eCode,dec=1;
- char code ;
- const char * strCh ;
-
- len = str.size() ;
- strCh = str.c_str();
- bCode= '0';
- eCode= '9';
- sum=0;
- for (int i=0; i<len; i++)
- {
- dec=1;
- for (int j=0; j<len-i-1 ; j++)
- dec = 0x10 * dec;
-
- code= strCh[i];
- //cout << code << " checked: \n";
- if ( (code >= bCode) && (code <=eCode) ){ //It's a digit number
- sum = sum + dec * (code-bCode) ;
- //cout << dec <<" Int added\n" ;
- }
- else if ( (code >= 'A') && (code <= 'F') ){ //It's a hex allowed char
- sum = sum + dec * (code- 'A' +10) ;
- //cout << dec << " Hex Added\n" ;
- }
- else {
- return 1;
- //cout << sum << " Azz Added\n" ;
- }
- }
- return 0;
-
-};
-
-int toInt (const string& str,int &sum)
-{
- int len, bCode,eCode,dec=1;
- char code ;
- const char * strCh ;
-
- len = str.size() ;
- strCh = str.c_str();
- bCode= '0';
- eCode= '9';
- sum=0;
- for (int i=0; i<len; i++)
- {
- dec=1;
- for (int j=0; j<len-i-1 ; j++)
- dec=10*dec;
- code= strCh[i];
- if ( (code < bCode) || (code >eCode) ) //It's not a digit number
- return 1;
- else
- sum = sum + dec * (code-bCode) ;
- }
- return 0;
-}
-/******************************************************************
- method : inTo
- field: integer & string class
- Converts an integer to a string
- INTEGER --->STRING
-*******************************************************************/
-string inTo(const int number){
- char buffer [CHAR_BUFFER_SIZE] ;
- sprintf (buffer, "%i" , number) ;
- return std::string(buffer);
-};
-
-/******************************************************************
- method : count
- field: string class
- Counts number of sub-string occurrences in str
-*******************************************************************/
-int count(const string& strMain,const string& sep){
- int n=0,found ;
- int l;
- //string str=strMain ;
- l = sep.length();
- found = strMain.find(sep) ;
- while (found!= -1){
- found = strMain.find(sep , found + l) ;
- ++n ;
- }
- return n ;
-};
-
-/******************************************************************
- method : split
- field: string class
- Splits a string into a vector of substring
- maxLenght: max dimension of vector (the last item of the vector will be the lasting part)
- trough: if trough == 1 the separator will be copied at the end of the left-substring
-*******************************************************************/
-vector<string> split(const string& str, const string& sep, int maxLength, int trough)
-{
- vector<string> strList ;
- int n,l,end, begin;
- string tmpStr=str ;
- l= sep.length();
- // Optional trough variable indicates that the separator
- // string remain in the array string
- if (trough) trough = l ;
- n = count(tmpStr,sep);
- if (n>maxLength) n = maxLength ;
- //n (or maxLength) is the number of separator to be found
- begin = 0;
- //cout << "->"<< str << " <--------> " << sep << ":\n";
- end = tmpStr.find(sep);
- for (int i=0; i<n; i++)
- {
- //cout << end << "<---END\n";
- strList.push_back( tmpStr.substr(begin,end +trough - begin) ) ;
- //cout << "##"<< tmpStr.substr(begin,end + trough - begin)<<"##\n" ;
- begin = end + l ;
- end= tmpStr.find(sep, begin) ;
- //tmpStr=tmpStr.substr(end+l, str.size() );
- }
- //cout << end << ">beg>end>" << tmpStr.length() ;
- strList.push_back(tmpStr.substr(begin, tmpStr.length() - begin ) ) ;
- //cout << "||"<< tmpStr.substr( begin,tmpStr.length() - begin )<<"||\n" ;
- return strList ;
-
-};
-
-/******************************************************************
- method : sp
- field: string class
- used to create a checkString
-*******************************************************************/
-string sp(const string& separator)
- {
- const string sep = "_SEP_" ;
- return sep + separator + sep ;
- }
-
-/******************************************************************
- method : checkFormat
- field: string class
- Chek the format of a string
- The format should be given as:
- TYPE+sep+SEPARATOR+sep+TYPE+sep+SEPARATOR+sep+ TYPE +...
- Returns: 0 No Error
- 1 Error Found
-*******************************************************************/
-int checkFormat (const string& format, const string& str)
-{
- string type , separator, tmpStr=str ;
- vector<string> form ;
- int len, pos, i;
- const string sep = "_SEP_" ;
- const string sepStr = "$STR$" ;
- const string sepInt = "$INT$" ;
- form =split (format,sep);
- len=form.size();
- for (i =1;i<len;i=i+2) {
- separator = form[i];
- pos = tmpStr.find(separator);
- if (pos ==-1)
- //No required separator found
- return 1 ;
- else
- //Required Separator successfully found
- type = tmpStr.substr (0, pos);
- tmpStr = tmpStr.substr( pos+separator.size() , tmpStr.size() );
- if (form[i-1] == sepInt)
- {
- pos = isInt(type);
- if (pos)
- return 1;
- }
- }
- type = tmpStr ;
- if (form[i-1] == sepInt)
- {
- pos = isInt(type);
- if (pos)
- return 1;
- }
- return 0 ;
-}
-
-/******************************************************************
- * method : replace
- * field: string class
- * Replace "what" value with "with" value
- *******************************************************************/
-void
-replace(string& where, const string& what, const string& with)
-{
- size_t fpos = where.find(what);
-
- while (fpos != string::npos) {
- where.replace(fpos, what.length(), with);
- fpos = where.find(what, fpos + what.length() + 1);
- }
-}
-
-} // exception namespace
-} // wmsutils namespace
-} // glite namespace
+++ /dev/null
-#ifndef GLITE_WMSGLITE_EXCEPTION_UTILS_H
-#define GLITE_WMSGLITE_EXCEPTION_UTILS_H
-/*
- * utils.h
- * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved.
- * Contributors are mentioned in the code where appropriate.
- *
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_STRINGSTREAM
-#include <sstream>
-#else
-#include <strstream>
-#endif
-
-#include <iostream>
-#include <vector>
-#include <string>
-#include <cstdlib>
-#include <cstdio>
-#include <ctime>
-#include <unistd.h>
-
-#define CHAR_BUFFER_SIZE 1024
-
-namespace glite {
-namespace wmsutils {
-namespace exception {
-
-/**
- * std:string useful JSUI common utilized methods
- *
- * @ingroup Common
- * @version 0.1
- * @date 15 April 2002
- * @author Alessandro Maraschini <alessandro.maraschini@datamat.it>
-*/
-
-/**
-* Check if a string can be converted into an integer
-* @ingroup Common
-*/
-int isInt (const std::string& str);
-/**
-* Converts a string into an Integer value
-* @ingroup Common
-*/
-int toInt (const std::string& str, int &sum);
-/**
-* Converts a string into an Hexasdecimal value
-* @ingroup Common
-*/
-int toHex (const std::string& str, int &sum);
-/**
-* Converts an integer into a string
-* @ingroup Common
-*/
-std::string inTo(int i);
-/**
-* Counts number of sub-string occurrences in a string
-* @ingroup Common
-*/
-int count(const std::string& strMain, const std::string& sep);
-/**
-* Splits a string into a vector of substring
-* @param str - The string to be parsed
-* @param sep - The separator to be found
-* @param maxLength - max dimension of vector (the last item of the vector will be the lasting part)
-* @param trough - if trough == 1 the separator will be copied at the end of the left-substring
-* @ingroup Common
-*/
-std::vector<std::string> split(const std::string& str, const std::string& sep, int maxLength =1000, int trough = 0);
-std::string sp(const std::string& separator);
-int checkFormat (const std::string& format, const std::string& str);
-
-void
-replace(std::string& where, const std::string& what, const std::string& with);
-
-} // exception namespace
-} // wmsglite namespace
-} // glite namespace
-
-#endif