Core: DeHtml, SqlExp: Insert, Update add methods with ValueMap parameter

git-svn-id: svn://ultimatepp.org/upp/trunk@5535 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-11-09 09:48:03 +00:00
parent 5430f0d7a7
commit 8949942c4f
7 changed files with 550 additions and 498 deletions

View file

@ -16,6 +16,8 @@ String Base64Decode(const char *s, const char *end);
String Base64Decode(const char *s, int len);
String Base64Decode(const String& data);
String DeHtml(const char *s);
class IpAddrInfo {
enum { COUNT = 32 };
struct Entry {

View file

@ -225,6 +225,34 @@ String Base64Decode(const String& data)
return Base64Decode(~data, data.GetLength());
}
String DeHtml(const char *s)
{
String result;
while(*s) {
if(*s == 31)
result.Cat(" ");
else
if(*s == '<')
result.Cat("&lt;");
else
if(*s == '>')
result.Cat("&gt;");
else
if(*s == '&')
result.Cat("&amp;");
else
if(*s == '\"')
result.Cat("&quot;");
else
if((byte)*s < ' ')
result.Cat(NFormat("&#%d;", (byte)*s));
else
result.Cat(*s);
s++;
}
return result;
}
void HttpCookie::Clear()
{
id.Clear();

View file

@ -65,6 +65,12 @@ st]_[@(0.0.255) char]_`*[*@3 s], [@(0.0.255) int]_[*@3 len])&]
e64 format]..&]
[s3; &]
[s4; &]
[s5;:DeHtml`(const char`*`): [_^String^ String]_[* DeHtml]([@(0.0.255) const]_[@(0.0.255) cha
r]_`*[*@3 s])&]
[s2;%% Escapes characters `'<`', `'>`', `'`&`', `'`\`"`' and characters
< 31 as html entities and escapes character 31 as `"`&nbsp;`".&]
[s3;%% &]
[s4; &]
[s5;:HttpResponse`(TcpSocket`&`,bool`,int`,const char`*`,const char`*`,const String`&`,const char`*`): [@(0.0.255) b
ool]_[* HttpResponse]([_^TcpSocket^ TcpSocket][@(0.0.255) `&]_[*@3 socket],
[@(0.0.255) bool]_[*@3 scgi], [@(0.0.255) int]_[*@3 code], [@(0.0.255) const]_[@(0.0.255) cha
@ -205,4 +211,4 @@ a digit, SCGI is assumed and the header is parsed as SCGI.&]
[s5;:HttpHeader`:`:HttpHeader`(`): [* HttpHeader]()&]
[s2;%% Default constructor.&]
[s3; &]
[s0;%% ]
[s0;%% ]]

View file

@ -1,4 +1,4 @@
topic "class Ref : private Moveable<Ref> ";
topic "Ref";
[2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,2#27521748481378242620020725143825:desc]
@ -89,4 +89,4 @@ ypeRef][@(0.0.255) `&]_[*@3 r])&]
[s5;:Ref`:`:Ref`(`): [* Ref]()&]
[s2;%% Default constructor, constructs empty Ref (no variable referenced,
no value can be assigned).&]
[s0;%% ]
[s0;%% ]]

View file

@ -447,7 +447,7 @@ requests, but it avoids identity checks to prevent CSRF attacks.&]
that are persistent for specific browser across requests. Implementation
is based on cookie, session variables are stored either in filesystem
or in database (see Skylark configuration for details). Session
variables reflected in shared variable space (means its values
variables are reflected in shared variable space (means its values
are accessible using [* Http`::operator`[`]]) and are distinguished
with `'.`' as the first character.&]
[s7; &]

View file

@ -344,6 +344,13 @@ SqlInsert& SqlInsert::operator()(Fields f, bool nokey)
return *this;
}
SqlInsert& SqlInsert::operator()(const ValueMap& data)
{
for(int i = 0; i < data.GetCount(); i++)
operator()((String)data.GetKey(i), data.GetValue(i));
return *this;
}
struct UpdateFieldOperator : public FieldOperator {
SqlUpdate *update;
@ -366,6 +373,13 @@ SqlUpdate& SqlUpdate::operator()(Fields f) {
return *this;
}
SqlUpdate& SqlUpdate::operator()(const ValueMap& data)
{
for(int i = 0; i < data.GetCount(); i++)
operator()((String)data.GetKey(i), data.GetValue(i));
return *this;
}
// ------------------------------------
SqlUpdate::operator SqlStatement() const {

View file

@ -621,6 +621,7 @@ public:
SqlInsert& operator()(const SqlId& column, SqlVal val) { Column(column, val); return *this; }
SqlInsert& operator()(const SqlId& column) { Column(column, column); return *this; }
SqlInsert& operator()(Fields f, bool nokey = false);
SqlInsert& operator()(const ValueMap& data);
SqlInsert& From(const SqlId& from);
SqlInsert& From(SqlSet _from) { from = _from; return *this; }
SqlInsert& From(SqlVal from) { return From(SqlSet(from)); }
@ -662,6 +663,7 @@ public:
SqlUpdate& operator()(const SqlId& column, SqlVal val) { Column(column, val); return *this; }
SqlUpdate& operator()(const SqlSet& cols, const SqlSet& val) { Column(cols, val); return *this; }
SqlUpdate& operator()(Fields f);
SqlUpdate& operator()(const ValueMap& data);
SqlUpdate& Where(SqlBool w) { where = w; return *this; }
operator SqlStatement() const;