Monday, 26 April 2010
Installed Erlang on OS X 10.6.3 Snow Leopard
Thursday, 22 April 2010
W3C schema for the RFC 1123 date format
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation><xs:documentation>Schema for RFC 1123 date format type</xs:documentation></xs:annotation>
<xs:simpleType name="RFC1123_date">
<xs:annotation><xs:documentation>RFC 1123 date format.</xs:documentation></xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="(Mon|Tue|Wed|Thu|Fri|Sat|Sun), [0-3][0-9] (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) 20[0-9][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] GMT">
</xs:restriction>
</xs:simpleType>
</xs:schema>
Wednesday, 17 March 2010
Python http PUT request
Wednesday, 3 March 2010
I wanted an iomanipulator to escape XML
class Wrapper{
std::string &m_data;
public:
typedef std::string::value_type value_type;
Wrapper(std::string & data):m_data(data){ }
std::string &str(){
return m_data;
}
};
std::ostream &
operator << (std::ostream & os, Wrapper & s);
std::ostream &
operator<< (std::ostream & os, Wrapper & s){
XmlEscape x(os);
for_each(s.str().begin(),s.str().end(),x);
return os;
}
where XmlEscape is a functor:
class XmlEscape{
static const char * m_chars;
static const char * m_replacements[];
static const unsigned int m_nchars=5;
std::ostream & m_os;
public:
XmlEscape(std::ostream & os);
void operator()(char c);
std::ostream & ostream();
};
with implementation:
const char * XmlEscape::m_chars ="&\'\"><";
const char * XmlEscape::m_replacements[]={"&", "'", """, ">", "<"};
XmlEscape::XmlEscape(std::ostream & os):m_os(os){
//nop
}
void
XmlEscape::operator()(char c){
unsigned int i(m_nchars);
while(i--){
if (c==m_chars[i]) {
m_os<<m_replacements[i];
return;
}
}
m_os<<c;
}
2. Adapt the stream