#include <ss.h>
List of all members.
Public Member Functions |
| TSs () |
| ~TSs () |
| TSs (TSIn &SIn) |
void | Save (TSOut &SOut) |
TSs & | operator= (const TSs &Ss) |
TStr & | At (const int &X, const int &Y) |
void | PutVal (const int &X, const int &Y, const TStr &Str) |
TStr | GetVal (const int &X, const int &Y) const |
int | GetXLen () const |
int | GetXLen (const int &Y) const |
int | GetYLen () const |
void | DelX (const int &X) |
void | DelY (const int &Y) |
int | SearchX (const int &Y, const TStr &Str) const |
int | SearchY (const int &X, const TStr &Str) const |
int | GetFlds () const |
int | GetFldX (const TStr &FldNm, const TStr &NewFldNm="", const int &Y=0) const |
int | GetFldY (const TStr &FldNm, const TStr &NewFldNm="", const int &X=0) const |
TStr | GetFldNm (const int &FldX) const |
void | SaveTxt (const TStr &FNm, const PNotify &Notify=NULL) const |
Static Public Member Functions |
static PSs | New () |
static PSs | Load (TSIn &SIn) |
static PSs | LoadTxt (const TSsFmt &SsFmt, const TStr &FNm, const PNotify &Notify=NULL, const bool &IsExcelEoln=true, const int &MxY=-1, const TIntV &AllowedColNV=TIntV(), const bool &IsQStr=true) |
static void | LoadTxtFldV (const TSsFmt &SsFmt, const PSIn &SIn, char &Ch, TStrV &FldValV, const bool &IsExcelEoln=true, const bool &IsQStr=true) |
static TSsFmt | GetSsFmtFromStr (const TStr &SsFmtNm) |
static TStr | GetStrFromSsFmt (const TSsFmt &SsFmt) |
static TStr | GetSsFmtNmVStr () |
Private Attributes |
TCRef | CRef |
TVec< PStrV > | CellStrVV |
Friends |
class | TPt< TSs > |
Detailed Description
Definition at line 18 of file ss.h.
Constructor & Destructor Documentation
Definition at line 22 of file ss.h.
Definition at line 24 of file ss.h.
Definition at line 25 of file ss.h.
Member Function Documentation
Definition at line 3 of file ss.cpp.
Definition at line 50 of file ss.h.
Definition at line 47 of file ss.h.
Definition at line 73 of file ss.cpp.
{
if (GetYLen()>Y){
int XLen=GetXLen(Y);
for (int X=0; X<XLen; X++){
if (GetVal(X, Y).GetTrunc()==FldNm){
if (!NewFldNm.Empty()){GetVal(X, Y)=NewFldNm;}
return X;
}
}
return -1;
} else {
return -1;
}
}
Definition at line 338 of file ss.cpp.
{
TChA ChA;
ChA+='(';
ChA+="tab"; ChA+=", ";
ChA+="comma"; ChA+=", ";
ChA+="semicolon"; ChA+=", ";
ChA+="space"; ChA+=", ";
ChA+="white"; ChA+=")";
return ChA;
}
Definition at line 26 of file ss.h.
PSs TSs::LoadTxt |
( |
const TSsFmt & |
SsFmt, |
|
|
const TStr & |
FNm, |
|
|
const PNotify & |
Notify = NULL , |
|
|
const bool & |
IsExcelEoln = true , |
|
|
const int & |
MxY = -1 , |
|
|
const TIntV & |
AllowedColNV = TIntV() , |
|
|
const bool & |
IsQStr = true |
|
) |
| [static] |
Definition at line 100 of file ss.cpp.
{
TNotify::OnNotify(Notify, ntInfo, TStr("Loading File ")+FNm+" ...");
PSIn SIn=TFIn::New(FNm);
PSs Ss=TSs::New();
if (!SIn->Eof()){
int X=0; int Y=0; int PrevX=-1; int PrevY=-1;
char Ch=SIn->GetCh(); TChA ChA;
while (!SIn->Eof()){
ChA.Clr();
if (IsQStr&&(Ch=='"')){
Ch=SIn->GetCh();
forever {
while ((!SIn->Eof())&&(Ch!='"')){
ChA+=Ch; Ch=SIn->GetCh();}
if (Ch=='"'){
Ch=SIn->GetCh();
if (Ch=='"'){ChA+=Ch; Ch=SIn->GetCh();}
else {break;}
}
}
} else {
if (SsFmt==ssfTabSep){
while ((!SIn->Eof())&&(Ch!='\t')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
ChA+=Ch; Ch=SIn->GetCh();
}
} else
if (SsFmt==ssfCommaSep){
while ((!SIn->Eof())&&(Ch!=',')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
ChA+=Ch; Ch=SIn->GetCh();
}
} else
if (SsFmt==ssfSemicolonSep){
while ((!SIn->Eof())&&(Ch!=';')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
ChA+=Ch; Ch=SIn->GetCh();
}
} else
if (SsFmt==ssfVBar){
while ((!SIn->Eof())&&(Ch!='|')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
ChA+=Ch; Ch=SIn->GetCh();
}
} else
if (SsFmt==ssfSpaceSep){
while ((!SIn->Eof())&&(Ch!=' ')&&(Ch!='\r')&&((Ch!='\n')||IsExcelEoln)){
ChA+=Ch; Ch=SIn->GetCh();
}
} else {
Fail;
}
}
if (PrevY!=Y){
if ((MxY!=-1)&&(Ss->CellStrVV.Len()==MxY)){break;}
Ss->CellStrVV.Add(TStrVP::New()); PrevY=Y;
int Recs=Ss->CellStrVV.Len();
if (Recs%1000==0){
TNotify::OnStatus(Notify, TStr::Fmt(" %d\r", Recs));}
}
if (AllowedColNV.Empty()||AllowedColNV.IsIn(X)){
Ss->CellStrVV[Y]->V.Add(ChA);
}
if (SIn->Eof()){
break;
} else
if ((SsFmt==ssfTabSep)&&(Ch=='\t')){
X++; Ch=SIn->GetCh();
} else
if ((SsFmt==ssfCommaSep)&&(Ch==',')){
X++; Ch=SIn->GetCh();
} else
if ((SsFmt==ssfSemicolonSep)&&(Ch==';')){
X++; Ch=SIn->GetCh();
} else
if ((SsFmt==ssfVBar)&&(Ch=='|')){
X++; Ch=SIn->GetCh();
} else
if ((SsFmt==ssfSpaceSep)&&(Ch==' ')){
X++; Ch=SIn->GetCh();
} else
if (Ch=='\r'){
if ((PrevX!=-1)&&(X!=PrevX)){
TNotify::OnNotify(Notify, ntWarn, "Number of fields is not the same!");}
PrevX=X; X=0; Y++; Ch=SIn->GetCh();
if ((Ch=='\n')&&(!SIn->Eof())){Ch=SIn->GetCh();}
} else
if (Ch=='\n'){
if ((PrevX!=-1)&&(X!=PrevX)){
TNotify::OnNotify(Notify, ntWarn, "Number of fields is not the same!");}
PrevX=X; X=0; Y++; Ch=SIn->GetCh();
if ((Ch=='\r')&&(!SIn->Eof())){Ch=SIn->GetCh();}
} else {
Fail;
}
}
}
int Recs=Ss->CellStrVV.Len();
TNotify::OnNotify(Notify, ntInfo, TStr::Fmt(" %d records read.", Recs));
TNotify::OnNotify(Notify, ntInfo, "... Done.");
return Ss;
}
void TSs::LoadTxtFldV |
( |
const TSsFmt & |
SsFmt, |
|
|
const PSIn & |
SIn, |
|
|
char & |
Ch, |
|
|
TStrV & |
FldValV, |
|
|
const bool & |
IsExcelEoln = true , |
|
|
const bool & |
IsQStr = true |
|
) |
| [static] |
Definition at line 228 of file ss.cpp.
{
if (!SIn->Eof()){
FldValV.Clr(false); int X=0;
if (Ch==TCh::NullCh){Ch=SIn->GetCh();}
TChA ChA;
while (!SIn->Eof()){
ChA.Clr();
if (IsQStr&&(Ch=='"')){
Ch=SIn->GetCh();
forever {
while ((!SIn->Eof())&&(Ch!='"')){
ChA+=Ch; Ch=SIn->GetCh();}
if (Ch=='"'){
Ch=SIn->GetCh();
if (Ch=='"'){ChA+=Ch; Ch=SIn->GetCh();}
else {break;}
}
}
} else {
if (SsFmt==ssfTabSep){
while ((!SIn->Eof())&&(Ch!='\t')&&(Ch!='\r')&&
((Ch!='\n')||IsExcelEoln)){
ChA+=Ch; Ch=SIn->GetCh();
}
if ((!ChA.Empty())&&(ChA.LastCh()=='\"')){
ChA.Pop();}
} else
if (SsFmt==ssfCommaSep){
while ((!SIn->Eof())&&(Ch!=',')&&(Ch!='\r')&&
((Ch!='\n')||IsExcelEoln)){
ChA+=Ch; Ch=SIn->GetCh();
}
} else
if (SsFmt==ssfSemicolonSep){
while ((!SIn->Eof())&&(Ch!=';')&&(Ch!='\r')&&
((Ch!='\n')||IsExcelEoln)){
ChA+=Ch; Ch=SIn->GetCh();
}
} else
if (SsFmt==ssfVBar){
while ((!SIn->Eof())&&(Ch!='|')&&(Ch!='\r')&&
((Ch!='\n')||IsExcelEoln)){
ChA+=Ch; Ch=SIn->GetCh();
}
} else {
Fail;
}
}
ChA.Trunc();
FldValV.Add(ChA);
if (SIn->Eof()){
break;
} else
if ((SsFmt==ssfTabSep)&&(Ch=='\t')){
X++; Ch=SIn->GetCh();
} else
if ((SsFmt==ssfCommaSep)&&(Ch==',')){
X++; Ch=SIn->GetCh();
} else
if ((SsFmt==ssfSemicolonSep)&&(Ch==';')){
X++; Ch=SIn->GetCh();
} else
if ((SsFmt==ssfVBar)&&(Ch=='|')){
X++; Ch=SIn->GetCh();
} else
if (Ch=='\r'){
Ch=SIn->GetCh();
if ((Ch=='\n')&&(!SIn->Eof())){Ch=SIn->GetCh();}
break;
} else
if (Ch=='\n'){
X=0; Ch=SIn->GetCh();
if ((Ch=='\r')&&(!SIn->Eof())){Ch=SIn->GetCh();}
break;
} else {
Fail;
}
}
}
}
Definition at line 23 of file ss.h.
TSs& TSs::operator= |
( |
const TSs & |
Ss | ) |
[inline] |
Definition at line 29 of file ss.h.
Definition at line 27 of file ss.h.
Definition at line 55 of file ss.cpp.
{
int YLen=GetYLen();
for (int Y=0; Y<YLen; Y++){
if (Str==GetVal(X, Y)){return Y;}}
return -1;
}
Friends And Related Function Documentation
friend class TPt< TSs > [friend] |
Definition at line 18 of file ss.h.
Member Data Documentation
Definition at line 20 of file ss.h.
Definition at line 18 of file ss.h.
The documentation for this class was generated from the following files: