TDbiAsciiTablePreparer.cxx File Reference

#include <fstream>
#include <sstream>
#include "TString.h"
#include "TSystem.h"
#include "TUrl.h"
#include "TSocket.h"
#include "TDbiAsciiTablePreparer.hxx"
#include <TSK_DBI_Log.hxx>
#include <MsgFormat.h>
Include dependency graph for TDbiAsciiTablePreparer.cxx:

Go to the source code of this file.

Functions

 ClassImp (TDbiAsciiTablePreparer) TString Validate(const TString &str)

Function Documentation

ClassImp ( TDbiAsciiTablePreparer   )  const

Definition at line 27 of file TDbiAsciiTablePreparer.cxx.

00038 {
00039    // internal use static func.
00040    //
00041    // - Does validation of string as coulmn names/types, very primitive so far.
00042    // - Returns corrected column string
00043 
00044    TString ret = str.Strip(TString::kBoth);
00045    Int_t spidx = 0;
00046    const char* s = ret.Data();
00047 
00048    if(s[0]=='\"' || s[strlen(s)-1]=='\"' ) {
00049       TString quote('\"');
00050       ret.ReplaceAll(quote,"");
00051       goto exit;
00052    }
00053    if( ret.IsNull() ||
00054       ((ret.Length()==1) && !isalpha(s[0]) ) ) return "wrong format";
00055 
00056    for (Ssiz_t i = 0; i < ret.Length(); i++) {
00057       if( !isalnum(s[i]) && !isspace(s[i]) &&
00058          s[i]!=')' && s[i]!='(' && s[i]!=',' &&
00059          s[i]!='_' && s[i]!='-' ) {
00060          return "wrong format";
00061       }
00062       if(isspace(s[i])) spidx = i;
00063    }
00064 
00065 exit:
00066    if(!spidx) ret += " TEXT NOT NULL";
00067    return ret;
00068 }


Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1