Update of /cvsroot/objecthandler/log4cxx-0.9.7/include/log4cxx/helpers
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25784/include/log4cxx/helpers
Added Files:
Makefile.am absolutetimedateformat.h appenderattachableimpl.h
boundedfifo.h class.h condition.h criticalsection.h
cyclicbuffer.h datagrampacket.h datagramsocket.h dateformat.h
datelayout.h datetimedateformat.h event.h exception.h
filewatchdog.h formattinginfo.h gnomexml.h inetaddress.h
intializationutil.h iso8601dateformat.h loader.h locale.h
loglog.h msxml.h mutex.h object.h objectimpl.h objectptr.h
onlyonceerrorhandler.h optionconverter.h patternconverter.h
patternparser.h properties.h propertyresourcebundle.h
relativetimedateformat.h resourcebundle.h semaphore.h
serversocket.h socket.h socketimpl.h socketinputstream.h
socketoutputstream.h strictmath.h stringhelper.h
stringtokenizer.h syslogwriter.h system.h tchar.h thread.h
threadspecificdata.h timezone.h transform.h xml.h
Log Message:
--- NEW FILE: Makefile.am ---
helpersincdir = $(includedir)/log4cxx/helpers
helpersinc_HEADERS= $(top_srcdir)/include/log4cxx/helpers/*.h
--- NEW FILE: datagrampacket.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_DATAGRAM_PACKET
#define _LOG4CXX_HELPERS_DATAGRAM_PACKET
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/inetaddress.h>
namespace log4cxx
{
namespace helpers
{
class DatagramPacket;
typedef helpers::ObjectPtrT<DatagramPacket> DatagramPacketPtr;
/** This class represents a datagram packet.
<p>Datagram packets are used to implement a connectionless packet
delivery service. Each message is routed from one machine to another
based solely on information contained within that packet. Multiple
packets sent from one machine to another might be routed differently,
and might arrive in any order.
*/
class LOG4CXX_EXPORT DatagramPacket : public helpers::ObjectImpl
{
protected:
/** the data for this packet. */
void * buf;
/** The offset of the data for this packet. */
int offset;
/** The length of the data for this packet. */
int length;
/** The IP address for this packet. */
InetAddress address;
/** The UDP port number of the remote host. */
int port;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramPacket)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(DatagramPacket)
END_LOG4CXX_CAST_MAP()
/** Constructs a DatagramPacket for receiving packets of length
<code>length</code>. */
DatagramPacket(void * buf, int length);
/** Constructs a datagram packet for sending packets of length
<code>length</code> to the specified port number on the specified
host. */
DatagramPacket(void * buf, int length, InetAddress address, int port);
/** Constructs a DatagramPacket for receiving packets of length
<code>length</code>, specifying an offset into the buffer. */
DatagramPacket(void * buf, int offset, int length);
/** Constructs a datagram packet for sending packets of length
<code>length</code> with offset <code>offset</code> to the
specified port number on the specified host. */
DatagramPacket(void * buf, int offset, int length, InetAddress address,
int port);
~DatagramPacket();
/** Returns the IP address of the machine to which this datagram
is being sent or from which the datagram was received. */
inline InetAddress getAddress() const
{ return address; }
/** Returns the data received or the data to be sent. */
inline void * getData() const
{ return buf; }
/** Returns the length of the data to be sent or the length of the
data received. */
inline int getLength() const
{ return length; }
/** Returns the offset of the data to be sent or the offset of the
data received. */
inline int getOffset() const
{ return offset; }
/** Returns the port number on the remote host to which this
datagram is being sent or from which the datagram was received. */
inline int getPort() const
{ return port; }
inline void setAddress(InetAddress address)
{ this->address = address; }
/** Set the data buffer for this packet. */
inline void setData(void * buf)
{ this->buf = buf; }
/** Set the data buffer for this packet. */
inline void setData(void * buf, int offset, int length)
{ this->buf = buf; this->offset = offset; this->length = length; }
/** Set the length for this packet. */
inline void setLength(int length)
{ this->length = length; }
inline void setPort(int port)
{ this->port = port; }
}; // class DatagramSocketImpl
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_DATAGRAM_SOCKET_IMPL
--- NEW FILE: objectptr.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_OBJECT_PTR_H
#define _LOG4CXX_HELPERS_OBJECT_PTR_H
#include <log4cxx/helpers/exception.h>
namespace log4cxx
{
namespace helpers
{
/** smart pointer to a Object descendant */
template<typename T> class ObjectPtrT
{
public:
template<typename InterfacePtr> ObjectPtrT(const InterfacePtr& p)
: p(0)
{
cast(p);
}
// Disable conversion using ObjectPtrT* specialization of
// template<typename InterfacePtr> ObjectPtrT(const InterfacePtr& p)
/* template<> explicit ObjectPtrT(ObjectPtrT* const & p) throw(IllegalArgumentException)
{
if (p == 0)
{
throw IllegalArgumentException(String());
}
else
{
this->p = p->p;
this->p->addRef();
}
}*/
ObjectPtrT(const int& null) //throw(IllegalArgumentException)
: p(0)
{
if (null != 0)
{
throw IllegalArgumentException(String());
}
}
ObjectPtrT() : p(0)
{
}
ObjectPtrT(T * p) : p(p)
{
if (this->p != 0)
{
this->p->addRef();
}
}
ObjectPtrT(const ObjectPtrT& p) : p(p.p)
{
if (this->p != 0)
{
this->p->addRef();
}
}
~ObjectPtrT()
{
if (this->p != 0)
{
this->p->releaseRef();
}
}
// Operators
template<typename InterfacePtr> ObjectPtrT& operator=(const InterfacePtr& p)
{
cast(p);
return *this;
}
ObjectPtrT& operator=(const ObjectPtrT& p)
{
if (this->p != p.p)
{
if (this->p != 0)
{
this->p->releaseRef();
}
this->p = p.p;
if (this->p != 0)
{
this->p->addRef();
}
}
return *this;
}
ObjectPtrT& operator=(const int& null) //throw(IllegalArgumentException)
{
if (null != 0)
{
throw IllegalArgumentException(String());
}
if (this->p != 0)
{
this->p->releaseRef();
this->p = 0;
}
return *this;
}
ObjectPtrT& operator=(T* p)
{
if (this->p != p)
{
if (this->p != 0)
{
this->p->releaseRef();
}
this->p = p;
if (this->p != 0)
{
this->p->addRef();
}
}
return *this;
}
bool operator==(const ObjectPtrT& p) const { return (this->p == p.p); }
bool operator!=(const ObjectPtrT& p) const { return (this->p != p.p); }
bool operator==(const T* p) const { return (this->p == p); }
bool operator!=(const T* p) const { return (this->p != p); }
T* operator->() {return p; }
const T* operator->() const {return p; }
T& operator*() const {return *p; }
operator T*() const {return p; }
template<typename InterfacePtr> void cast(const InterfacePtr& p)
{
if (this->p != 0)
{
this->p->releaseRef();
this->p = 0;
}
if (p != 0)
{
this->p = (T*)p->cast(T::getStaticClass());
if (this->p != 0)
{
this->p->addRef();
}
}
}
public:
T * p;
};
}
}
#endif //_LOG4CXX_HELPERS_OBJECT_PTR_H
--- NEW FILE: msxml.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_MSXML_H
#define _LOG4CXX_HELPERS_MSXML_H
#include <log4cxx/config.h>
#ifdef HAVE_MS_XML
#include <log4cxx/helpers/xml.h>
#include <log4cxx/helpers/objectimpl.h>
//#ifndef __IXMLDOMDocument_FWD_DEFINED__
#import "msxml.dll"
//#endif
namespace log4cxx
{
namespace helpers
{
class LOG4CXX_EXPORT MsXMLDOMNode :
virtual public XMLDOMNode,
virtual public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(MsXMLDOMNode)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLDOMNode)
END_LOG4CXX_CAST_MAP()
MsXMLDOMNode(MSXML::IXMLDOMNodePtr node);
virtual XMLDOMNodeListPtr getChildNodes();
virtual XMLDOMNodeType getNodeType()
{ return NOT_IMPLEMENTED_NODE; }
virtual XMLDOMDocumentPtr getOwnerDocument();
protected:
MSXML::IXMLDOMNodePtr node;
};
class LOG4CXX_EXPORT MsXMLDOMDocument :
virtual public XMLDOMDocument,
virtual public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(MsXMLDOMDocument)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLDOMDocument)
LOG4CXX_CAST_ENTRY(XMLDOMNode)
END_LOG4CXX_CAST_MAP()
MsXMLDOMDocument();
MsXMLDOMDocument(MSXML::IXMLDOMDocumentPtr document);
~MsXMLDOMDocument();
virtual XMLDOMNodeListPtr getChildNodes();
virtual XMLDOMNodeType getNodeType()
{ return XMLDOMNode::DOCUMENT_NODE; }
virtual XMLDOMDocumentPtr getOwnerDocument();
virtual void load(const String& fileName);
virtual XMLDOMElementPtr getDocumentElement();
virtual XMLDOMElementPtr getElementById(const String& tagName, const String& elementId);
protected:
MSXML::IXMLDOMDocumentPtr document;
bool mustCallCoUninitialize;
};
class LOG4CXX_EXPORT MsXMLDOMElement :
virtual public XMLDOMElement,
virtual public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(MsXMLDOMElement)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLDOMElement)
LOG4CXX_CAST_ENTRY(XMLDOMNode)
END_LOG4CXX_CAST_MAP()
MsXMLDOMElement(MSXML::IXMLDOMElementPtr element);
virtual XMLDOMNodeListPtr getChildNodes();
virtual XMLDOMNodeType getNodeType()
{ return XMLDOMNode::ELEMENT_NODE; }
virtual XMLDOMDocumentPtr getOwnerDocument();
virtual String getTagName();
virtual String getAttribute(const String& name);
protected:
MSXML::IXMLDOMElementPtr element;
};
class LOG4CXX_EXPORT MsXMLDOMNodeList :
virtual public XMLDOMNodeList,
virtual public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(MsXMLDOMNodeList)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLDOMNodeList)
END_LOG4CXX_CAST_MAP()
MsXMLDOMNodeList(MSXML::IXMLDOMNodeListPtr nodeList);
virtual int getLength();
virtual XMLDOMNodePtr item(int index);
protected:
MSXML::IXMLDOMNodeListPtr nodeList;
};
} // namespace helpers
}; // namespace log4cxx
#endif // HAVE_MS_XML
#endif // _LOG4CXX_HELPERS_MSXML_H
--- NEW FILE: filewatchdog.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_FILEWATCHDOG_H
#define _LOG4CXX_HELPERS_FILEWATCHDOG_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/thread.h>
#include <time.h>
namespace log4cxx
{
namespace helpers
{
/**
Check every now and then that a certain file has not changed. If it
has, then call the #doOnChange method.
*/
class LOG4CXX_EXPORT FileWatchdog : public Thread
{
public:
/**
The default delay between every file modification check, set to 60
seconds. */
static long DEFAULT_DELAY /*= 60000*/;
protected:
/**
The name of the file to observe for changes.
*/
String filename;
/**
The delay to observe between every check.
By default set DEFAULT_DELAY.*/
long delay;
time_t lastModif;
bool warnedAlready;
bool interrupted;
protected:
FileWatchdog(const String& filename);
virtual void doOnChange() = 0;
void checkAndConfigure();
public:
/**
Set the delay to observe between each check of the file changes.
*/
void setDelay(long delay)
{ this->delay = delay; }
void run();
void start();
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_FILEWATCHDOG_H
--- NEW FILE: propertyresourcebundle.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_PROPERTY_RESOURCE_BUNDLE_H
#define _LOG4CXX_HELPERS_PROPERTY_RESOURCE_BUNDLE_H
#include <log4cxx/helpers/resourcebundle.h>
#include <log4cxx/helpers/properties.h>
namespace log4cxx
{
namespace helpers
{
class PropertyResourceBundle;
typedef ObjectPtrT<PropertyResourceBundle> PropertyResourceBundlePtr;
/**
PropertyResourceBundle is a concrete subclass of ResourceBundle that
manages resources for a locale using a set of static strings from a
property file.
*/
class LOG4CXX_EXPORT PropertyResourceBundle : public ResourceBundle
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(PropertyResourceBundle)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(PropertyResourceBundle)
LOG4CXX_CAST_ENTRY_CHAIN(ResourceBundle)
END_LOG4CXX_CAST_MAP()
/**
Creates a property resource bundle.
@param inStream property file to read from.
@throw IOException if an error occurred when reading from the
input stream.
*/
PropertyResourceBundle(istream& inStream);
virtual String getString(const String& key) const;
protected:
Properties properties;
}; // class PropertyResourceBundle
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_PROPERTY_RESOURCE_BUNDLE_H
--- NEW FILE: system.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_SYSTEM_H
#define _LOG4CXX_HELPERS_SYSTEM_H
#include <log4cxx/config.h>
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/exception.h>
namespace log4cxx
{
namespace helpers
{
class Properties;
/** The System class contains several useful class fields and methods.
It cannot be instantiated.
*/
class LOG4CXX_EXPORT System
{
public:
/** Returns the current time in milliseconds since midnight (0 hour),
January 1, 1970.
Returns the current time in milliseconds. Note that while the unit of
time of the return value is a millisecond, the granularity of the value
depends on the underlying operating system and may be larger. For
example, many operating systems measure time in units of tens of
milliseconds.
@return the difference, measured in milliseconds, between the current
time and midnight, January 1, 1970 UTC.
*/
static int64_t currentTimeMillis();
/**
Gets the system property indicated by the specified key.
@param key the name of the system property.
@return the string value of the system property, or the default value if
there is no property with that key.
@throws IllegalArgumentException if key is empty.
*/
static String getProperty(const String& key);
/**
Sets the system property indicated by the specified key.
@param key the name of the system property.
@param value the value of the system property.
@throws IllegalArgumentException if key is empty.
*/
static void setProperty(const String& key, const String& value);
static void setProperties(const Properties& props);
};
} // namespace helpers
}; // namespace log4cxx
#endif //_LOG4CXX_HELPERS_SYSTEM_H
--- NEW FILE: resourcebundle.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_RESOURCE_BUNDLE_H
#define _LOG4CXX_HELPERS_RESOURCE_BUNDLE_H
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/locale.h>
namespace log4cxx
{
namespace helpers
{
class LOG4CXX_EXPORT MissingResourceException : public Exception
{
};
class ResourceBundle;
typedef ObjectPtrT<ResourceBundle> ResourceBundlePtr;
/**
Resource bundles contain locale-specific objects
*/
class LOG4CXX_EXPORT ResourceBundle : public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(ResourceBundle)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(ResourceBundle)
END_LOG4CXX_CAST_MAP()
/**
Gets a string for the given key from this resource bundle or one of
its parents. Calling this method is equivalent to calling
@param key the key for the desired string
@return the string for the given key
@throw MissingResourceException - if no object for the given key
can be found
*/
virtual String getString(const String& key) const = 0;
/**
Gets a resource bundle using the specified base name and locale
@param baseName the base name of the resource bundle, a fully
qualified class name or property filename
@param locale the locale for which a resource bundle is desired
*/
static ResourceBundlePtr getBundle(const String& baseName,
const Locale& locale);
protected:
/*
Sets the parent bundle of this bundle. The parent bundle is
searched by #getString when this bundle does not contain a particular
resource.
Parameters:
parent - this bundle's parent bundle.
*/
inline void setParent(const ResourceBundlePtr& parent)
{ this->parent = parent; }
/**
The parent bundle of this bundle.
The parent bundle is searched by #getString when this bundle does
not contain a particular resource.
*/
ResourceBundlePtr parent;
}; // class ResourceBundle
} // namespace helpers
}; // namespace log4cxx
#endif
--- NEW FILE: gnomexml.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_GNOMEXML_H
#define _LOG4CXX_HELPERS_GNOMEXML_H
#include <log4cxx/config.h>
#ifdef HAVE_LIBXML2
#include <log4cxx/helpers/xml.h>
#include <log4cxx/helpers/objectimpl.h>
#include <libxml/tree.h>
namespace log4cxx
{
namespace helpers
{
class GnomeXMLDOMNode :
virtual public XMLDOMNode,
virtual public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(GnomeXMLDOMNode)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLDOMNode)
END_LOG4CXX_CAST_MAP()
GnomeXMLDOMNode(xmlNodePtr node);
virtual XMLDOMNodeListPtr getChildNodes();
virtual XMLDOMNodeType getNodeType()
{ return NOT_IMPLEMENTED_NODE; }
virtual XMLDOMDocumentPtr getOwnerDocument();
protected:
xmlNodePtr node;
};
class GnomeXMLDOMDocument :
virtual public XMLDOMDocument,
virtual public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(GnomeXMLDOMDocument)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLDOMDocument)
LOG4CXX_CAST_ENTRY(XMLDOMNode)
END_LOG4CXX_CAST_MAP()
GnomeXMLDOMDocument();
GnomeXMLDOMDocument(xmlDocPtr document);
~GnomeXMLDOMDocument();
virtual XMLDOMNodeListPtr getChildNodes();
virtual XMLDOMNodeType getNodeType()
{ return XMLDOMNode::DOCUMENT_NODE; }
virtual XMLDOMDocumentPtr getOwnerDocument();
virtual void load(const String& fileName);
virtual XMLDOMElementPtr getDocumentElement();
virtual XMLDOMElementPtr getElementById(
const String& tagName, const String& elementId);
protected:
xmlDocPtr document;
bool ownDocument;
};
class GnomeXMLDOMElement :
virtual public XMLDOMElement,
virtual public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(GnomeXMLDOMElement)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLDOMElement)
LOG4CXX_CAST_ENTRY(XMLDOMNode)
END_LOG4CXX_CAST_MAP()
GnomeXMLDOMElement(xmlNodePtr element);
virtual XMLDOMNodeListPtr getChildNodes();
virtual XMLDOMNodeType getNodeType()
{ return XMLDOMNode::ELEMENT_NODE; }
virtual XMLDOMDocumentPtr getOwnerDocument();
virtual String getTagName();
virtual String getAttribute(const String& name);
protected:
xmlNodePtr element;
};
class GnomeXMLDOMNodeList :
virtual public XMLDOMNodeList,
virtual public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(GnomeXMLDOMNodeList)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(XMLDOMNodeList)
END_LOG4CXX_CAST_MAP()
GnomeXMLDOMNodeList(xmlNodePtr firstChild);
virtual int getLength();
virtual XMLDOMNodePtr item(int index);
protected:
xmlNodePtr firstChild;
xmlNodePtr currentChild;
int currentIndex;
};
} // namespace helpers
}; // namespace log4cxx
#endif // HAVE_LIBXML2
#endif // _LOG4CXX_HELPERS_MSXML_H
--- NEW FILE: datelayout.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_DATE_LAYOUT_H
#define _LOG4CXX_HELPERS_DATE_LAYOUT_H
#include <log4cxx/layout.h>
namespace log4cxx
{
namespace helpers
{
class DateFormat;
class TimeZone;
typedef helpers::ObjectPtrT<TimeZone> TimeZonePtr;
/**
This abstract layout takes care of all the date related options and
formatting work.
*/
class LOG4CXX_EXPORT DateLayout : public Layout
{
public:
/**
String constant designating no time information. Current value of
this constant is <b>NULL</b>.
*/
static String NULL_DATE_FORMAT;
/**
String constant designating relative time. Current value of
this constant is <b>RELATIVE</b>.
*/
static String RELATIVE_TIME_DATE_FORMAT;
static String DATE_FORMAT_OPTION;
static String TIMEZONE_OPTION;
private:
String timeZoneID;
String dateFormatOption;
protected:
DateFormat * dateFormat;
public:
DateLayout();
virtual ~DateLayout();
virtual void activateOptions();
virtual void setOption(const String& option, const String& value);
/**
The value of the <b>DateFormat</b> option should be either an
argument to the constructor of helpers::DateFormat or one of
the srings <b>"NULL"</b>, <b>"RELATIVE"</b>, <b>"ABSOLUTE"</b>,
<b>"DATE"</b> or <b>"ISO8601</b>.
*/
inline void setDateFormat(const String& dateFormat)
{ this->dateFormatOption = dateFormat; }
/**
Returns value of the <b>DateFormat</b> option.
*/
inline const String& getDateFormat() const
{ return dateFormatOption; }
/**
The <b>TimeZoneID</b> option is a time zone ID string in the format
expected by the <code>locale</code> C++ standard class.
*/
inline void setTimeZone(const String& timeZone)
{ this->timeZoneID = timeZone; }
/**
Returns value of the <b>TimeZone</b> option.
*/
inline const String& getTimeZone() const
{ return timeZoneID; }
void formatDate(ostream &os, const spi::LoggingEventPtr& event) const;
protected:
/**
Sets the DateFormat used to format date and time in the time zone
determined by <code>timeZone</code> parameter. The
helpers::DateFormat DateFormat used
will depend on the <code>dateFormatType</code>.
<p>The recognized types are #NULL_DATE_FORMAT,
#RELATIVE_TIME_DATE_FORMAT,
helpers::AbsoluteTimeDateFormat#ABS_TIME_DATE_FORMAT,
helpers::AbsoluteTimeDateFormat#DATE_AND_TIME_DATE_FORMAT and
helpers::AbsoluteTimeDateFormat#ISO8601_DATE_FORMAT. If the
<code>dateFormatType</code> is not one of the above, then the
argument is assumed to be a date pattern for
helpers::DateFormat.
*/
void setDateFormat(const String& dateFormatType,
const TimeZonePtr& timeZone);
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_DATE_LAYOUT_H
--- NEW FILE: relativetimedateformat.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_RELATIVE_TIME_DATE_FORMAT_H
#define _LOG4CXX_HELPERS_RELATIVE_TIME_DATE_FORMAT_H
#include <log4cxx/helpers/dateformat.h>
#include <log4cxx/helpers/system.h>
namespace log4cxx
{
namespace helpers
{
/**
Formats a date by printing the number of seconds
elapsed since the start of the application. This is the fastest
printing DateFormat in the package.
*/
class LOG4CXX_EXPORT RelativeTimeDateFormat : public DateFormat
{
protected:
int64_t startTime;
public:
RelativeTimeDateFormat()
: DateFormat(_T(""), 0), startTime(System::currentTimeMillis())
{
}
virtual void format(ostream& os, int64_t time) const
{
os << (time - startTime);
}
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_RELATIVE_TIME_DATE_FORMAT_H
--- NEW FILE: class.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_CLASS_H
#define _LOG4CXX_HELPERS_CLASS_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/objectptr.h>
namespace log4cxx
{
namespace helpers
{
class Object;
typedef ObjectPtrT<Object> ObjectPtr;
/**
Thrown when an application tries to create an instance of a class using
the newInstance method in class Class, but the specified class object
cannot be instantiated because it is an interface or is an abstract class.
*/
class LOG4CXX_EXPORT InstantiationException : public Exception
{
public:
InstantiationException() : Exception(_T("Abstract class")) {}
};
/**
Thrown when an application tries to load in a class through its
string name but no definition for the class with the specified name
could be found.
*/
class LOG4CXX_EXPORT ClassNotFoundException : public Exception
{
public:
ClassNotFoundException(const String& className);
};
class LOG4CXX_EXPORT Class
{
public:
Class(const String& name);
virtual ~Class () {}
virtual ObjectPtr newInstance() const;
const String& toString() const;
const String& getName() const;
static const Class& forName(const String& className);
protected:
static void registerClass(const Class * newClass);
String name;
};
} // namespace log4cxx
}; // namespace helper
#endif //_LOG4CXX_HELPERS_CLASS_H
--- NEW FILE: criticalsection.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_CRITICAL_SECTION_H
#define _LOG4CXX_HELPERS_CRITICAL_SECTION_H
#include <log4cxx/config.h>
#ifdef HAVE_PTHREAD
#include <pthread.h>
#elif defined(HAVE_MS_THREAD)
#include <windows.h>
#endif
namespace log4cxx
{
namespace helpers
{
class LOG4CXX_EXPORT CriticalSection
{
public:
CriticalSection();
~CriticalSection();
void lock();
void unlock();
unsigned long getOwningThread();
#ifdef HAVE_PTHREAD
pthread_mutex_t mutex;
#elif defined(HAVE_MS_THREAD)
CRITICAL_SECTION mutex;
#endif
unsigned long owningThread;
};
/** CriticalSection helper class to be used on call stack
*/
class WaitAccess
{
public:
/// lock a critical section
WaitAccess(CriticalSection& cs) : cs(cs)
{
cs.lock();
locked = true;
}
/** automatically unlock the critical section
if unlock has not be called.
*/
~WaitAccess()
{
if (locked)
{
unlock();
}
}
/// unlock the critical section
void unlock()
{
cs.unlock();
locked = false;
}
private:
/// the CriticalSection to be automatically unlocked
CriticalSection& cs;
/// verify the CriticalSection state
bool locked;
};
} // namespace helpers
}; // namespace log4cxx
#endif //_LOG4CXX_HELPERS_CRITICAL_SECTION_H
--- NEW FILE: transform.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_TRANSFORM_H
#define _LOG4CXX_HELPERS_TRANSFORM_H
#include <log4cxx/helpers/tchar.h>
namespace log4cxx
{
namespace helpers
{
/**
Utility class for transforming strings.
*/
class LOG4CXX_EXPORT Transform
{
private:
static String CDATA_START;
static String CDATA_END;
static String CDATA_PSEUDO_END;
static String CDATA_EMBEDED_END;
static String::size_type CDATA_END_LEN;
public:
/**
* This method takes a string which may contain HTML tags (ie,
* <b>, <table>, etc) and replaces any '<' and '>'
* characters with respective predefined entity references.
*
* @param buf output stream where to write the modified string.
* @param input The text to be converted.
* @return The input string with the characters '<' and '>' replaced with
* &lt; and &gt; respectively.
* */
static void appendEscapingTags(
ostream& buf, const String& input);
/**
* Ensures that embeded CDEnd strings (]]>) are handled properly
* within message, NDC and throwable tag text.
*
* @param buf output stream holding the XML data to this point. The
* initial CDStart (<![CDATA[) and final CDEnd (]]>) of the CDATA
* section are the responsibility of the calling method.
* @param input The String that is inserted into an existing CDATA
* Section within buf.
*/
static void appendEscapingCDATA(
ostream& buf, const String& input);
}; // class Transform
} // namespace helpers
}; //namespace log4cxx
#endif // _LOG4CXX_HELPERS_TRANSFORM_H
--- NEW FILE: socketoutputstream.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_H
#define _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h>
namespace log4cxx
{
namespace helpers
{
class Socket;
typedef ObjectPtrT<Socket> SocketPtr;
class SocketOutputStream;
typedef ObjectPtrT<SocketOutputStream> SocketOutputStreamPtr;
class LOG4CXX_EXPORT SocketOutputStream : public ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(SocketOutputStream)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(SocketOutputStream)
END_LOG4CXX_CAST_MAP()
SocketOutputStream(SocketPtr socket);
~SocketOutputStream();
void write(const void * buffer, size_t len);
void write(unsigned int value);
void write(int value);
void write(unsigned long value);
void write(long value);
void write(const String& value);
// some write functions are missing ...
/** Close the stream and dereference the socket.
*/
void close();
/** Flushes this output stream and forces any buffered output
bytes to be written out.
*/
void flush();
protected:
SocketPtr socket;
/** memory stream buffer */
/* class membuf :
public std::basic_streambuf<char, std::char_traits<char> >
{
public:
const void * buffer() const;
const size_t size() const;
}*/
unsigned char * beg, * cur, * end;
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_H
--- NEW FILE: iso8601dateformat.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_ISO_8601_DATE_FORMAT_H
#define _LOG4CXX_HELPERS_ISO_8601_DATE_FORMAT_H
#include <log4cxx/helpers/dateformat.h>
namespace log4cxx
{
namespace helpers
{
/**
Formats a date in the format <b>\%Y-\%m-\%d \%H:\%M:\%S,\%Q</b> for example
"1999-11-27 15:49:37,459".
<p>Refer to the
<a href=http://www.cl.cam.ac.uk/~mgk25/iso-time.html>summary of the
International Standard Date and Time Notation</a> for more
information on this format.
*/
class LOG4CXX_EXPORT ISO8601DateFormat : public DateFormat
{
public:
ISO8601DateFormat(const TimeZonePtr& timeZone)
: DateFormat(_T("%Y-%m-%d %H:%M:%S,%Q"), timeZone) {}
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_ISO_8601_DATE_FORMAT_H
--- NEW FILE: syslogwriter.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/inetaddress.h>
namespace log4cxx
{
namespace helpers
{
class DatagramSocket;
typedef helpers::ObjectPtrT<DatagramSocket> DatagramSocketPtr;
/**
SyslogWriter is a wrapper around the DatagramSocket class
it writes text to the specified host on the port 514 (UNIX syslog)
*/
class LOG4CXX_EXPORT SyslogWriter
{
public:
SyslogWriter(const String& syslogHost);
void write(const String& string);
private:
String syslogHost;
InetAddress address;
DatagramSocketPtr ds;
};
} // namespace helpers
}; // namespace log4cxx
--- NEW FILE: exception.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_EXCEPTION_H
#define _LOG4CXX_HELPERS_EXCEPTION_H
#include <log4cxx/helpers/tchar.h>
namespace log4cxx
{
namespace helpers
{
/** The class Exception and its subclasses indicate conditions that a
reasonable application might want to catch.
*/
class LOG4CXX_EXPORT Exception
{
public:
Exception() {}
Exception(const String& message): message(message) {}
inline const String& getMessage() { return message; }
protected:
String message;
}; // class Exception
/** RuntimeException is the parent class of those exceptions that can be
thrown during the normal operation of the process.
*/
class LOG4CXX_EXPORT RuntimeException : public Exception
{
public:
RuntimeException() {}
RuntimeException(const String& message)
: Exception(message) {}
}; // class RuntimeException
/** Thrown when an application attempts to use null in a case where an
object is required.
*/
class LOG4CXX_EXPORT NullPointerException : public RuntimeException
{
public:
NullPointerException() {}
NullPointerException(const String& message)
: RuntimeException(message) {}
}; // class NullPointerException
/** Thrown to indicate that a method has been passed
an illegal or inappropriate argument.*/
class LOG4CXX_EXPORT IllegalArgumentException : public RuntimeException
{
public:
IllegalArgumentException(const String& message)
: RuntimeException(message) {}
}; // class IllegalArgumentException
/** Signals that an I/O exception of some sort has occurred. This class
is the general class of exceptions produced by failed or interrupted
I/O operations.
*/
class LOG4CXX_EXPORT IOException : public Exception
{
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_EXCEPTION_H
--- NEW FILE: cyclicbuffer.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_CYCLICBUFFER_H
#define _LOG4CXX_HELPERS_CYCLICBUFFER_H
#include <log4cxx/spi/loggingevent.h>
#include <vector>
namespace log4cxx
{
namespace helpers
{
/**
CyclicBuffer is used by other appenders to hold {@link spi::LoggingEvent
LoggingEvents} for immediate or differed display.
<p>This buffer gives read access to any element in the buffer not
just the first or last element.
*/
class LOG4CXX_EXPORT CyclicBuffer
{
std::vector<spi::LoggingEventPtr> ea;
int first;
int last;
int numElems;
int maxSize;
public:
/**
Instantiate a new CyclicBuffer of at most <code>maxSize</code>
events.
The <code>maxSize</code> argument must a positive integer.
@param maxSize The maximum number of elements in the buffer.
@throws IllegalArgumentException if <code>maxSize</code>
is negative.
*/
CyclicBuffer(int maxSize);
~CyclicBuffer();
/**
Add an <code>event</code> as the last event in the buffer.
*/
void add(const spi::LoggingEventPtr& event);
/**
Get the <i>i</i>th oldest event currently in the buffer. If
<em>i</em> is outside the range 0 to the number of elements
currently in the buffer, then <code>null</code> is returned.
*/
spi::LoggingEventPtr get(int i);
int getMaxSize() const
{ return maxSize; }
/**
Get the oldest (first) element in the buffer. The oldest element
is removed from the buffer.
*/
spi::LoggingEventPtr get();
/**
Get the number of elements in the buffer. This number is
guaranteed to be in the range 0 to <code>maxSize</code>
(inclusive).
*/
int length() const
{ return numElems; }
/**
Resize the cyclic buffer to <code>newSize</code>.
@throws IllegalArgumentException if <code>newSize</code> is negative.
*/
void resize(int newSize);
}; // class CyclicBuffer
} //namespace helpers
}; //namespace log4cxx
#endif //_LOG4CXX_HELPERS_CYCLICBUFFER_H
--- NEW FILE: timezone.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_TIMEZONE_H
#define _LOG4CXX_HELPERS_TIMEZONE_H
#include <log4cxx/config.h>
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h>
#include <map>
namespace log4cxx
{
namespace helpers
{
class TimeZone;
typedef helpers::ObjectPtrT<TimeZone> TimeZonePtr;
class LOG4CXX_EXPORT TimeZone : public helpers::ObjectImpl
{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(TimeZone)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(TimeZone)
END_LOG4CXX_CAST_MAP()
TimeZone(const String& ID);
~TimeZone();
/**
Returns the offset of this time zone from UTC at the specified
date. If Daylight Saving Time is in effect at the specified date,
the offset value is adjusted with the amount of daylight saving.
@param date the date represented in milliseconds since January 1,
1970 00:00:00 GMT
@return the amount of time in milliseconds to add to UTC to get
local time.
*/
int getOffset(int64_t date) const;
static TimeZonePtr getDefault();
static TimeZonePtr getTimeZone(const String& ID);
/**
Queries if the given date is in daylight savings time in this time
zone.
@param date the given Date.
@return true if the given date is in daylight savings time, false,
otherwise.
*/
bool inDaylightTime(int64_t date) const;
/**
Returns the amount of time to be added to local standard time to
get local wall clock time.
@return the amount of saving time in milliseconds
*/
inline int getDSTSavings() const
{ return DSTSavings; }
/**
Returns the amount of time in milliseconds to add to UTC to get
standard time in this time zone.
Because this value is not affected by daylight saving time, it is
called raw offset.
@return the amount of raw offset time in milliseconds to add to
UTC.
*/
inline int getRawOffset() const
{ return rawOffset; }
/**
Queries if this time zone uses daylight savings time.
@return true if this time zone uses daylight savings time, false,
otherwise.
*/
inline bool useDaylightTime() const
{ return DSTSavings != 0; }
protected:
String ID;
int rawOffset;
int DSTSavings;
class Rule
{
public:
Rule(int year);
int year;
int64_t startDate;
int64_t endDate;
};
typedef std::map<long, Rule *> RuleMap;
mutable RuleMap rules;
static TimeZonePtr defaultTimeZone;
};
}
}
#endif //_LOG4CXX_HELPERS_TIMEZONE_H
--- NEW FILE: socketinputstream.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_SOCKET_INPUT_STREAM_H
#define _LOG4CXX_HELPERS_SOCKET_INPUT_STREAM_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/exception.h>
namespace log4cxx
{
namespace helpers
{
class Socket;
typedef ObjectPtrT<Socket> SocketPtr;
class SocketInputStream;
typedef ObjectPtrT<SocketInputStream> SocketInputStreamPtr;
class LOG4CXX_EXPORT EOFException : public Exception
{
};
class LOG4CXX_EXPORT SocketInputStream : public ObjectImpl
{
private:
static size_t DEFAULT_BUFFER_SIZE;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(SocketInputStream)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(SocketInputStream)
END_LOG4CXX_CAST_MAP()
SocketInputStream(SocketPtr socket);
SocketInputStream(SocketPtr socket, size_t bufferSize);
~SocketInputStream();
void read(void * buffer, size_t len) const;
void read(unsigned int &value) const;
void read(int &value) const;
void read(unsigned long &value) const;
void read(long &value) const;
void read(String& value) const;
// some read functions are missing ...
/** Close the stream and dereference the socket.
*/
void close();
protected:
SocketPtr socket;
size_t bufferSize;
unsigned char * memBuffer;
size_t currentPos;
size_t maxPos;
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_H
--- NEW FILE: socketimpl.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_SOCKET_IMPL
#define _LOG4CXX_HELPERS_SOCKET_IMPL
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/inetaddress.h>
#include <log4cxx/helpers/exception.h>
namespace log4cxx
{
namespace helpers
{
/** Thrown to indicate that there is an error in the underlying
protocol, such as a TCP error.
*/
class LOG4CXX_EXPORT SocketException : public IOException
{
public:
SocketException();
};
/** Signals that an error occurred while attempting to connect a socket
to a remote address and port. Typically, the connection was refused
remotely (e.g., no process is listening on the remote address/port).
*/
class LOG4CXX_EXPORT ConnectException : public SocketException
{
};
/** Signals that an error occurred while attempting to bind a socket to
a local address and port. Typically, the port is in use, or the
requested local address could not be assigned.
*/
class LOG4CXX_EXPORT BindException : public SocketException
{
};
/** Signals that an I/O operation has been interrupted. An
InterruptedIOException is thrown to indicate that an input or output
transfer has been terminated because the thread performing it was
interrupted. The field bytesTransferred indicates how many bytes were
successfully transferred before the interruption occurred.
*/
class LOG4CXX_EXPORT InterruptedIOException : public IOException
{
};
/** Signals that a timeout has occurred on a socket read or accept.
*/
class LOG4CXX_EXPORT SocketTimeoutException : public InterruptedIOException
{
};
class SocketImpl;
typedef helpers::ObjectPtrT<SocketImpl> SocketImplPtr;
/** @brief Default Socket Implementation.
This implementation does not implement any security check.
*/
class LOG4CXX_EXPORT SocketImpl : public helpers::ObjectImpl
{
protected:
/** The IP address of the remote end of this socket. */
InetAddress address;
/** The file descriptor object for this socket. */
int fd;
/** The local port number to which this socket is connected. */
int localport;
/** The port number on the remote host to which
this socket is connected. */
int port;
int timeout;
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(SocketImpl)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(SocketImpl)
END_LOG4CXX_CAST_MAP()
SocketImpl();
~SocketImpl();
/** @brief Accepts a connection.
@param s the connection
@throw SocketTimeoutException if a timeout was previously set with
setSoTimeout and the timeout has been reached.
@throw SocketException if an I/O error occurs when accepting the
connection
*/
void accept(SocketImplPtr s);
/** @brief Returns the number of bytes that can be read from this socket
without blocking.
@return the number of bytes that can be read from this socket
without blocking.
*/
int available();
/** Binds this socket to the specified port number
on the specified host.
@param host the host address
@param port the port number.
@exception BindException if an I/O error occurs when binding this socket.
*/
void bind(InetAddress host, int port);
/** Closes this socket. */
void close();
/** Connects this socket to the specified port number
on the specified host.
*/
void connect(InetAddress address, int port);
/** Connects this socket to the specified port on the named host. */
void connect(const String& host, int port);
/** Creates either a stream or a datagram socket. */
void create(bool stream);
/** Returns the value of this socket's fd field. */
inline int getFileDescriptor() const
{ return fd; }
/** Returns the value of this socket's address field. */
inline InetAddress getInetAddress() const
{ return address; }
/** Returns the value of this socket's localport field. */
inline int getLocalPort() const
{ return localport; }
/** Returns the value of this socket's port field. */
inline int getPort() const
{ return port; }
/** Sets the maximum queue length for incoming connection
indications (a request to connect) to the count argument.
*/
void listen(int backlog);
/** Returns the address and port of this socket as a String.
*/
String toString() const;
size_t read(void * buf, size_t len) const;
size_t write(const void * buf, size_t len);
/** Retrive setting for SO_TIMEOUT.
*/
int getSoTimeout() const;
/** Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
*/
void setSoTimeout(int timeout);
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_SOCKET_IMPL
--- NEW FILE: dateformat.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_DATE_FORMAT_H
#define _LOG4CXX_HELPERS_DATE_FORMAT_H
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/timezone.h>
namespace log4cxx
{
namespace helpers
{
/**
Concrete class for formatting and parsing dates in a
locale-sensitive manner.
*/
class LOG4CXX_EXPORT DateFormat
{
public:
DateFormat(const String& dateFormat);
DateFormat(const String& dateFormat, const TimeZonePtr& timeZone);
virtual ~DateFormat () {}
virtual void format(ostream& os, int64_t time) const;
String format(int64_t timeMillis) const;
protected:
TimeZonePtr timeZone;
String dateFormat;
};
} // namespace helpers
}; // namespace log4cxx
#endif //_LOG4CXX_HELPERS_DATE_FORMAT_H
--- NEW FILE: datetimedateformat.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H
#define _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H
#include <log4cxx/helpers/dateformat.h>
namespace log4cxx
{
namespace helpers
{
/**
Formats a date in the format <b>\%d-\%m-\%Y \%H:\%M:\%S,\%Q</b> for example,
"06 Nov 1994 15:49:37,459".
*/
class LOG4CXX_EXPORT DateTimeDateFormat : public DateFormat
{
public:
DateTimeDateFormat(const TimeZonePtr& timeZone)
: DateFormat(_T("%d %b %Y %H:%M:%S,%Q"), timeZone) {}
};
} // namespace helpers
}; // namespace log4cxx
#endif // _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H
--- NEW FILE: threadspecificdata.h ---
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in wri...
[truncated message content] |