Patch level : 2.1 nopatch

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Roba utile ai nuovi report


git-svn-id: svn://10.65.10.50/trunk@11943 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2004-04-07 16:09:39 +00:00
parent eb544f8aef
commit e0a0ba645b
4 changed files with 68 additions and 41 deletions

View File

@ -731,9 +731,8 @@ TConfig::TConfig(int which_config, const char* paragraph)
break;
case CONFIG_GUI:
{
TFilename gui = CGetCampoIni();
gui.rtrim(9);
gui << "gui.ini";
const TFilename ini = CGetCampoIni();
TFilename gui = ini.path(); gui.add("gui.ini");
bool ok = gui.exist();
if (!ok)
{

View File

@ -45,11 +45,14 @@ bool real::is_real (const char *s)
const long double n = _atold(s);
if (n == 0.0)
{
for(; *s; s++) if (*s != '0' && *s != ' ' && *s != '.')
return FALSE;
for(; *s; s++)
{
if (strchr("0. ", *s) == NULL)
return false;
}
}
}
return TRUE;
return true;
}
real::real (const char *s)

View File

@ -53,31 +53,37 @@ const TString& EscapeSequence(char cStart, istream& inf)
{
for (char c = inf.get(); c != ';'; c = inf.get())
str << c;
if (str == "lt") return str ="<";
if (str == "gt") return str =">";
if (str == "nbsp") return str =" ";
if (str == "Agrave") return str ="À";
if (str == "Egrave") return str ="È";
if (str == "Eacuto") return str ="É";
if (str == "Igrave") return str ="Ì";
if (str == "Ograve") return str ="Ò";
if (str == "Ugrave") return str ="Ù";
if (str == "agrave") return str ="à";
if (str == "egrave") return str ="è";
if (str == "eacuto") return str ="é";
if (str == "igrave") return str ="ì";
if (str == "ograve") return str ="ò";
if (str == "ugrave") return str ="ù";
if (str[0] == '#')
{
str[0] = hex2int((const char*)str+1);
str[1] = '\0';
} else
if (str[0] >= '0' && str[0] <= '9')
{
str[0] = atoi(str);
str[1] = '\0';
}
else
{
if (str == "lt") return str ="<";
if (str == "gt") return str =">";
if (str == "nbsp") return str =" ";
if (str == "Agrave") return str ="À";
if (str == "Egrave") return str ="È";
if (str == "Eacuto") return str ="É";
if (str == "Igrave") return str ="Ì";
if (str == "Ograve") return str ="Ò";
if (str == "Ugrave") return str ="Ù";
if (str == "agrave") return str ="à";
if (str == "egrave") return str ="è";
if (str == "eacuto") return str ="é";
if (str == "igrave") return str ="ì";
if (str == "ograve") return str ="ò";
if (str == "ugrave") return str ="ù";
const char tmp[2] = { cStart, '\0' };
str.insert(tmp);
} else
if (cStart == '%')
{
for (int i = 0; i < 2; i++)
str << inf.get();
char c = hex2int(str);
str = c;
const char tmp[2] = { cStart, '\0' };
str.insert(tmp);
}
}
return str;
@ -87,11 +93,11 @@ void WriteXmlString(ostream& outf, const char* str)
{
for (int i = 0; str[i]; i++)
{
char c = str[i];
if (c < 0 || strchr("<>/&", c) != NULL)
const char c = str[i];
if ((c < ' ' && c != '\n' && c != '\r') || strchr("<>/&", c) != NULL)
{
unsigned int n = (unsigned char)c;
TString8 tmp; tmp.format("%%%02X", n);
const unsigned int n = (unsigned char)c;
TString8 tmp; tmp.format("&#%02X;", n);
tmp.print_on(outf);
}
else
@ -204,6 +210,8 @@ bool TXmlItem::GetWord(istream& inf, TString& str) const
str << char(cFirstChar);
if (strchr("<=/>", cFirstChar) != NULL)
return true; // Simboli terminali
if (cFirstChar == '&')
str = EscapeSequence(cFirstChar, inf);
}
while (!inf.eof())
@ -226,7 +234,10 @@ bool TXmlItem::GetWord(istream& inf, TString& str) const
inf.putback(char(c));
break;
}
str << char(c);
if (c == '&')
str << EscapeSequence(c, inf);
else
str << char(c);
}
}
return str.not_empty();
@ -241,6 +252,7 @@ int TXmlItem::ReadTag(istream& inf)
if (str[0] != '<') // No tag = sequence of words
{
bool bFirstChar = true;
while (!inf.eof())
{
char c = inf.get();
@ -254,7 +266,7 @@ int TXmlItem::ReadTag(istream& inf)
str << ' ';
bFirstChar = false;
}
if (c == '&' || c == '#' || c == '%')
if (c == '&')
str << EscapeSequence(c, inf);
else
str << c;
@ -429,9 +441,7 @@ void TXmlItem::Write(ostream& outf, int tab) const
TAssoc_array& ass = *m_Attributes;
FOR_EACH_ASSOC_OBJECT(ass, h, k, a)
{
outf << ' ';
outf.write(k, strlen(k));
outf << '=';
outf << ' ' << k << '=';
const TXmlAttr* attr = (const TXmlAttr*)a;
attr->Write(outf);
}
@ -458,7 +468,9 @@ void TXmlItem::Write(ostream& outf, int tab) const
outf << ' ' << '/' << '>';
}
else
GetText().print_on(outf);
{
WriteXmlString(outf, GetText());
}
}
void TXmlItem::AsString(TString& str) const
@ -513,6 +525,18 @@ TXmlItem* TXmlItem::FindFirst(const char* strTag) const
return ((TXmlItem*)this)->ForEach(FindFirstCallback, (long)strTag);
}
TXmlItem* TXmlItem::FindFirstChild(const char* strTag) const
{
for (int i = 0; i < GetChildren(); i++)
{
TXmlItem* c = GetChild(i);
if (c->GetTag() == strTag)
return c;
}
return NULL;
}
TXmlItem::TXmlItem()
: m_strTag(15), m_strText(NULL), m_Attributes(NULL), m_Children(NULL)
{ }

View File

@ -68,7 +68,8 @@ public:
bool Load(const char* strFilename);
TXmlItem* ForEach(XmlItemCallback cb, long jolly = 0);
TXmlItem* FindFirst(const char* strTag) const;
TXmlItem* FindFirst(const char* strTag) const; // Recursive
TXmlItem* FindFirstChild(const char* strTag) const; // First level only
TXmlItem();
~TXmlItem();