mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-13 14:45:36 +02:00
synchronized trunk
This commit is contained in:
@@ -265,6 +265,9 @@
|
||||
<File
|
||||
RelativePath=".\src\DynamicAnyHolder.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicStruct.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Environment.cpp">
|
||||
</File>
|
||||
@@ -584,6 +587,9 @@
|
||||
<File
|
||||
RelativePath=".\include\Poco\DynamicFactory.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DynamicStruct.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Environment.h">
|
||||
</File>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Version="8,00"
|
||||
Name="Foundation"
|
||||
ProjectGUID="{8164D41D-B053-405B-826C-CF37AC0EF176}"
|
||||
RootNamespace="Foundation"
|
||||
@@ -379,6 +379,10 @@
|
||||
RelativePath=".\src\DynamicAnyHolder.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicStruct.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Environment.cpp"
|
||||
>
|
||||
@@ -803,6 +807,10 @@
|
||||
RelativePath=".\include\Poco\DynamicFactory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DynamicStruct.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Environment.h"
|
||||
>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id: //poco/Main/Foundation/Makefile#44 $
|
||||
# $Id: //poco/Main/Foundation/Makefile#45 $
|
||||
#
|
||||
# Makefile for Poco Foundation
|
||||
#
|
||||
@@ -29,7 +29,7 @@ objects = ArchiveStrategy ASCIIEncoding AsyncChannel Base64Decoder Base64Encoder
|
||||
ThreadPool ActiveDispatcher Timer Timespan Timestamp Timezone Token URI \
|
||||
FileStreamFactory URIStreamFactory URIStreamOpener UTF16Encoding Windows1252Encoding \
|
||||
UTF8Encoding UnicodeConverter UUID UUIDGenerator Void Format \
|
||||
Pipe PipeImpl PipeStream DynamicAny DynamicAnyHolder SharedMemory \
|
||||
Pipe PipeImpl PipeStream DynamicAny DynamicAnyHolder DynamicStruct SharedMemory \
|
||||
FileStream Unicode UTF8String \
|
||||
AsyncIOCommand AsyncIOEvent AsyncIOChannel AsyncStreamChannel \
|
||||
adler32 compress crc32 deflate gzio infback inffast inflate inftrees \
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Base64Decoder.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Base64Decoder.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Base64Decoder.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -67,6 +67,10 @@ private:
|
||||
|
||||
static unsigned char IN_ENCODING[256];
|
||||
static bool IN_ENCODING_INIT;
|
||||
|
||||
private:
|
||||
Base64DecoderBuf(const Base64DecoderBuf&);
|
||||
Base64DecoderBuf& operator = (const Base64DecoderBuf&);
|
||||
};
|
||||
|
||||
|
||||
@@ -83,6 +87,10 @@ public:
|
||||
|
||||
protected:
|
||||
Base64DecoderBuf _buf;
|
||||
|
||||
private:
|
||||
Base64DecoderIOS(const Base64DecoderIOS&);
|
||||
Base64DecoderIOS& operator = (const Base64DecoderIOS&);
|
||||
};
|
||||
|
||||
|
||||
@@ -93,6 +101,10 @@ class Foundation_API Base64Decoder: public Base64DecoderIOS, public std::istream
|
||||
public:
|
||||
Base64Decoder(std::istream& istr);
|
||||
~Base64Decoder();
|
||||
|
||||
private:
|
||||
Base64Decoder(const Base64Decoder&);
|
||||
Base64Decoder& operator = (const Base64Decoder&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Base64Encoder.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Base64Encoder.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Base64Encoder.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -83,6 +83,9 @@ private:
|
||||
static const unsigned char OUT_ENCODING[64];
|
||||
|
||||
friend class Base64DecoderBuf;
|
||||
|
||||
Base64EncoderBuf(const Base64EncoderBuf&);
|
||||
Base64EncoderBuf& operator = (const Base64EncoderBuf&);
|
||||
};
|
||||
|
||||
|
||||
@@ -100,6 +103,10 @@ public:
|
||||
|
||||
protected:
|
||||
Base64EncoderBuf _buf;
|
||||
|
||||
private:
|
||||
Base64EncoderIOS(const Base64EncoderIOS&);
|
||||
Base64EncoderIOS& operator = (const Base64EncoderIOS&);
|
||||
};
|
||||
|
||||
|
||||
@@ -114,6 +121,10 @@ class Foundation_API Base64Encoder: public Base64EncoderIOS, public std::ostream
|
||||
public:
|
||||
Base64Encoder(std::ostream& ostr);
|
||||
~Base64Encoder();
|
||||
|
||||
private:
|
||||
Base64Encoder(const Base64Encoder&);
|
||||
Base64Encoder& operator = (const Base64Encoder&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// BufferedBidirectionalStreamBuf.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#5 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#6 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -178,6 +178,9 @@ private:
|
||||
char_type* _pReadBuffer;
|
||||
char_type* _pWriteBuffer;
|
||||
openmode _mode;
|
||||
|
||||
BasicBufferedBidirectionalStreamBuf(const BasicBufferedBidirectionalStreamBuf&);
|
||||
BasicBufferedBidirectionalStreamBuf& operator = (const BasicBufferedBidirectionalStreamBuf&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// BufferedStreamBuf.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedStreamBuf.h#4 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedStreamBuf.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -170,6 +170,9 @@ private:
|
||||
std::streamsize _bufsize;
|
||||
char_type* _pBuffer;
|
||||
openmode _mode;
|
||||
|
||||
BasicBufferedStreamBuf(const BasicBufferedStreamBuf&);
|
||||
BasicBufferedStreamBuf& operator = (const BasicBufferedStreamBuf&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Channel.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Channel.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Channel.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
@@ -87,6 +87,10 @@ public:
|
||||
|
||||
protected:
|
||||
virtual ~Channel();
|
||||
|
||||
private:
|
||||
Channel(const Channel&);
|
||||
Channel& operator = (const Channel&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DynamicAny.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAny.h#9 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAny.h#10 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -64,7 +64,7 @@ class Foundation_API DynamicAny
|
||||
/// String truncation is allowed -- it is possible to convert between string and character when string length is
|
||||
/// greater than 1. An empty string gets converted to the char '\0', a non-empty string is truncated to the first character.
|
||||
///
|
||||
/// Bolean conversion are performed as follows:
|
||||
/// Boolean conversion is performed as follows:
|
||||
///
|
||||
/// A string value "false" (not case sensitive) or "0" can be converted to a boolean value false, any other string
|
||||
/// not being false by the above criteria evaluates to true (e.g: "hi" -> true).
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator == (const T& other)
|
||||
bool operator == (const T& other) const
|
||||
/// Equality operator
|
||||
{
|
||||
T value;
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
return value == other;
|
||||
}
|
||||
|
||||
bool operator == (const char* other)
|
||||
bool operator == (const char* other) const
|
||||
/// Equality operator
|
||||
{
|
||||
std::string value;
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator != (const T& other)
|
||||
bool operator != (const T& other) const
|
||||
/// Inequality operator
|
||||
{
|
||||
T value;
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
return value != other;
|
||||
}
|
||||
|
||||
bool operator != (const char* other)
|
||||
bool operator != (const char* other) const
|
||||
/// Inequality operator
|
||||
{
|
||||
std::string value;
|
||||
@@ -213,14 +213,63 @@ public:
|
||||
return value != other;
|
||||
}
|
||||
|
||||
const std::type_info& type() const;
|
||||
bool isArray() const;
|
||||
/// Returns true if DynamicAny represents a vector
|
||||
|
||||
bool isStruct() const;
|
||||
/// Returns true if DynamicAny represents a struct
|
||||
|
||||
DynamicAny& operator[](std::vector<DynamicAny>::size_type n);
|
||||
/// Index operator, only use on DynamicAnys where isArray
|
||||
/// returns true! In all other cases a BadCastException is thrown!
|
||||
|
||||
const DynamicAny& operator[](std::vector<DynamicAny>::size_type n) const;
|
||||
/// const Index operator, only use on DynamicAnys where isArray
|
||||
/// returns true! In all other cases a BadCastException is thrown!
|
||||
|
||||
DynamicAny& operator[](const std::string& name);
|
||||
/// Index operator by name, only use on DynamicAnys where isStruct
|
||||
/// returns true! In all other cases a BadCastException is thrown!
|
||||
|
||||
const DynamicAny& operator[](const std::string& name) const;
|
||||
/// Index operator by name, only use on DynamicAnys where isStruct
|
||||
/// returns true! In all other cases a BadCastException is thrown!
|
||||
|
||||
const std::type_info& type() const;
|
||||
/// Returns the type information of the stored content.
|
||||
|
||||
static DynamicAny parse(const std::string& val);
|
||||
/// Parses the string which must be in JSON format
|
||||
|
||||
static std::string toString(const DynamicAny& any);
|
||||
/// Converts the DynamicAny to a string in JSON format. Note that toString will return
|
||||
/// a different result than any.convert<std::string>()!
|
||||
|
||||
private:
|
||||
static DynamicAny parse(const std::string& val, std::string::size_type& offset);
|
||||
/// Parses the string which must be in JSON format
|
||||
|
||||
static DynamicAny parseObject(const std::string& val, std::string::size_type& pos);
|
||||
static DynamicAny parseArray(const std::string& val, std::string::size_type& pos);
|
||||
static std::string parseString(const std::string& val, std::string::size_type& pos);
|
||||
static void skipWhiteSpace(const std::string& val, std::string::size_type& pos);
|
||||
private:
|
||||
DynamicAnyHolder* _pHolder;
|
||||
};
|
||||
|
||||
|
||||
inline bool DynamicAny::isArray() const
|
||||
{
|
||||
return _pHolder->isArray();
|
||||
}
|
||||
|
||||
|
||||
inline bool DynamicAny::isStruct() const
|
||||
{
|
||||
return _pHolder->isStruct();
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
378
Foundation/include/Poco/DynamicStruct.h
Normal file
378
Foundation/include/Poco/DynamicStruct.h
Normal file
@@ -0,0 +1,378 @@
|
||||
//
|
||||
// DynamicStruct.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicStruct.h#9 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
// Module: DynamicStruct
|
||||
//
|
||||
// Definition of the DynamicStruct class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_DynamicStruct_INCLUDED
|
||||
#define Foundation_DynamicStruct_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/DynamicAny.h"
|
||||
#include "Poco/DynamicAnyHolder.h"
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API DynamicStruct
|
||||
/// DynamicStruct allows to define a named collection of DynamicAnys
|
||||
{
|
||||
public:
|
||||
typedef std::map<std::string, DynamicAny> Data;
|
||||
typedef Data::iterator Iterator;
|
||||
typedef Data::const_iterator ConstIterator;
|
||||
|
||||
DynamicStruct();
|
||||
/// Creates an empty DynamicStruct
|
||||
|
||||
DynamicStruct(const Data &val);
|
||||
/// Creates the DynamicStruct from the given value.
|
||||
|
||||
virtual ~DynamicStruct();
|
||||
/// Destroys the DynamicStruct.
|
||||
|
||||
DynamicAny& operator[](const std::string& name);
|
||||
/// Returns the DynamicAny with the given name, creates an entry if not found.
|
||||
|
||||
const DynamicAny& operator[](const std::string& name) const;
|
||||
/// Returns the DynamicAny with the given name, throws a
|
||||
/// NotFoundException if the data member is not found.
|
||||
|
||||
bool contains(const std::string& name) const;
|
||||
/// Returns true if the DynamicStruct contains a member with the given
|
||||
/// name
|
||||
|
||||
Iterator find(const std::string& name);
|
||||
/// Returns an iterator, pointing to the <name,DynamicAny> pair containing
|
||||
/// the element, or it returns end() if the member was not found
|
||||
|
||||
ConstIterator find(const std::string& name) const;
|
||||
/// Returns a const iterator, pointing to the <name,DynamicAny> pair containing
|
||||
/// the element, or it returns end() if the member was not found
|
||||
|
||||
Iterator end();
|
||||
/// Returns the end iterator for the DynamicStruct
|
||||
|
||||
ConstIterator end() const;
|
||||
/// Returns the end const iterator for the DynamicStruct
|
||||
|
||||
Iterator begin();
|
||||
/// Returns the begin iterator for the DynamicStruct
|
||||
|
||||
ConstIterator begin() const;
|
||||
/// Returns the begin const iterator for the DynamicStruct
|
||||
|
||||
std::pair<DynamicStruct::Iterator, bool> insert(const std::string& key, const DynamicAny& value);
|
||||
/// Inserts a <name, DynamicAny> pair into the DynamicStruct,
|
||||
/// returns a pair containing the iterator and a boolean which
|
||||
/// indicates success or not (is true, when insert succeeded, false,
|
||||
/// when already another element was present, in this case Iterator
|
||||
/// points to that other element)
|
||||
|
||||
std::pair<DynamicStruct::Iterator, bool> insert(const DynamicStruct::Data::value_type& aPair);
|
||||
/// Inserts a <name, DynamicAny> pair into the DynamicStruct,
|
||||
/// returns a pair containing the iterator and a boolean which
|
||||
/// indicates success or not (is true, when insert succeeded, false,
|
||||
/// when already another element was present, in this case Iterator
|
||||
/// points to that other element)
|
||||
|
||||
DynamicStruct::Data::size_type erase(const std::string& key);
|
||||
/// Erases the element if found, returns number of elements deleted
|
||||
|
||||
void erase(DynamicStruct::Iterator it);
|
||||
/// Erases the element at the given position
|
||||
|
||||
bool empty() const;
|
||||
/// Returns true if the DynamicStruct doesn't contain any members
|
||||
|
||||
DynamicStruct::Data::size_type size() const;
|
||||
/// Returns the number of members the DynamicStruct contains
|
||||
|
||||
std::set<std::string> members() const;
|
||||
/// Returns a sorted collection containing all member names
|
||||
|
||||
private:
|
||||
Data _data;
|
||||
};
|
||||
|
||||
|
||||
inline DynamicAny& DynamicStruct::operator[](const std::string& name)
|
||||
{
|
||||
return _data.operator [](name);
|
||||
}
|
||||
|
||||
|
||||
inline bool DynamicStruct::contains(const std::string& name) const
|
||||
{
|
||||
return find(name) != end();
|
||||
}
|
||||
|
||||
|
||||
inline DynamicStruct::Iterator DynamicStruct::find(const std::string& name)
|
||||
{
|
||||
return _data.find(name);
|
||||
}
|
||||
|
||||
|
||||
inline DynamicStruct::ConstIterator DynamicStruct::find(const std::string& name) const
|
||||
{
|
||||
return _data.find(name);
|
||||
}
|
||||
|
||||
|
||||
inline DynamicStruct::Iterator DynamicStruct::end()
|
||||
{
|
||||
return _data.end();
|
||||
}
|
||||
|
||||
|
||||
inline DynamicStruct::ConstIterator DynamicStruct::end() const
|
||||
{
|
||||
return _data.end();
|
||||
}
|
||||
|
||||
|
||||
inline DynamicStruct::Iterator DynamicStruct::begin()
|
||||
{
|
||||
return _data.begin();
|
||||
}
|
||||
|
||||
|
||||
inline DynamicStruct::ConstIterator DynamicStruct::begin() const
|
||||
{
|
||||
return _data.begin();
|
||||
}
|
||||
|
||||
|
||||
inline std::pair<DynamicStruct::Iterator, bool> DynamicStruct::insert(const std::string& key, const DynamicAny& value)
|
||||
{
|
||||
return insert(std::make_pair(key, value));
|
||||
}
|
||||
|
||||
|
||||
inline std::pair<DynamicStruct::Iterator, bool> DynamicStruct::insert(const DynamicStruct::Data::value_type& aPair)
|
||||
{
|
||||
return _data.insert(aPair);
|
||||
}
|
||||
|
||||
|
||||
inline DynamicStruct::Data::size_type DynamicStruct::erase(const std::string& key)
|
||||
{
|
||||
return _data.erase(key);
|
||||
}
|
||||
|
||||
|
||||
inline void DynamicStruct::erase(DynamicStruct::Iterator it)
|
||||
{
|
||||
_data.erase(it);
|
||||
}
|
||||
|
||||
|
||||
inline bool DynamicStruct::empty() const
|
||||
{
|
||||
return _data.empty();
|
||||
}
|
||||
|
||||
|
||||
inline DynamicStruct::Data::size_type DynamicStruct::size() const
|
||||
{
|
||||
return _data.size();
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
class DynamicAnyHolderImpl<DynamicStruct >: public DynamicAnyHolder
|
||||
{
|
||||
public:
|
||||
DynamicAnyHolderImpl(const DynamicStruct& val): _val(val)
|
||||
{
|
||||
}
|
||||
|
||||
~DynamicAnyHolderImpl()
|
||||
{
|
||||
}
|
||||
|
||||
const std::type_info& type() const
|
||||
{
|
||||
return typeid(DynamicStruct);
|
||||
}
|
||||
|
||||
void convert(Int8& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to Int8");
|
||||
}
|
||||
|
||||
void convert(Int16& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to Int16");
|
||||
}
|
||||
|
||||
void convert(Int32& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to Int32");
|
||||
}
|
||||
|
||||
void convert(Int64& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to Int64");
|
||||
}
|
||||
|
||||
void convert(UInt8& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to UInt8");
|
||||
}
|
||||
|
||||
void convert(UInt16& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to UInt16");
|
||||
}
|
||||
|
||||
void convert(UInt32& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to UInt32");
|
||||
}
|
||||
|
||||
void convert(UInt64& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to UInt64");
|
||||
}
|
||||
|
||||
void convert(bool& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to bool");
|
||||
}
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to float");
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to double");
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast DynamicStruct type to char");
|
||||
}
|
||||
|
||||
void convert(std::string& val) const
|
||||
{
|
||||
// Serialize in JSON format: equals an object
|
||||
|
||||
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
|
||||
val.append("{ ");
|
||||
DynamicStruct::ConstIterator it = _val.begin();
|
||||
DynamicStruct::ConstIterator itEnd = _val.end();
|
||||
if (!_val.empty())
|
||||
{
|
||||
DynamicAny key(it->first);
|
||||
appendJSONString(val, key);
|
||||
val.append(" : ");
|
||||
appendJSONString(val, it->second);
|
||||
++it;
|
||||
}
|
||||
for (; it != itEnd; ++it)
|
||||
{
|
||||
val.append(", ");
|
||||
DynamicAny key(it->first);
|
||||
appendJSONString(val, key);
|
||||
val.append(" : ");
|
||||
appendJSONString(val, it->second);
|
||||
}
|
||||
|
||||
val.append(" }");
|
||||
|
||||
}
|
||||
|
||||
void convert(Poco::DateTime&) const
|
||||
{
|
||||
throw BadCastException("DynamicStruct -> Poco::DateTime");
|
||||
}
|
||||
|
||||
void convert(Poco::LocalDateTime&) const
|
||||
{
|
||||
throw BadCastException("DynamicStruct -> Poco::LocalDateTime");
|
||||
}
|
||||
|
||||
void convert(Poco::Timestamp&) const
|
||||
{
|
||||
throw BadCastException("DynamicStruct -> Poco::Timestamp");
|
||||
}
|
||||
|
||||
DynamicAnyHolder* clone() const
|
||||
{
|
||||
return new DynamicAnyHolderImpl(_val);
|
||||
}
|
||||
|
||||
const DynamicStruct& value() const
|
||||
{
|
||||
return _val;
|
||||
}
|
||||
|
||||
bool isArray() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isStruct() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
DynamicAny& operator[](const std::string& name)
|
||||
{
|
||||
return _val.operator[](name);
|
||||
}
|
||||
|
||||
const DynamicAny& operator[](const std::string& name) const
|
||||
{
|
||||
return _val.operator[](name);
|
||||
}
|
||||
|
||||
private:
|
||||
DynamicStruct _val;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_DynamicStruct_INCLUDED
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Glob.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Glob.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Glob.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@@ -73,9 +73,10 @@ public:
|
||||
enum Options
|
||||
/// Flags that modify the matching behavior.
|
||||
{
|
||||
GLOB_DEFAULT = 0x00, /// default behavior
|
||||
GLOB_DOT_SPECIAL = 0x01, /// '*' and '?' do not match '.' at beginning of subject
|
||||
GLOB_DIRS_ONLY = 0x80 /// only glob for directories (for internal use only)
|
||||
GLOB_DEFAULT = 0x00, /// default behavior
|
||||
GLOB_DOT_SPECIAL = 0x01, /// '*' and '?' do not match '.' at beginning of subject
|
||||
GLOB_FOLLOW_SYMLINKS = 0x02, /// follow symbolic links
|
||||
GLOB_DIRS_ONLY = 0x80 /// only glob for directories (for internal use only)
|
||||
};
|
||||
|
||||
Glob(const std::string& pattern, int options = 0);
|
||||
@@ -141,6 +142,7 @@ protected:
|
||||
bool matchAfterAsterisk(std::string::const_iterator itp, const std::string::const_iterator& endp, std::string::const_iterator its, const std::string::const_iterator& ends);
|
||||
bool matchSet(std::string::const_iterator& itp, const std::string::const_iterator& endp, char c);
|
||||
static void collect(const Path& pathPattern, const Path& base, const Path& current, const std::string& pattern, std::set<std::string>& files, int options);
|
||||
static bool isDirectory(const Path& path, bool followSymlink);
|
||||
|
||||
private:
|
||||
std::string _pattern;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HMACEngine.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/HMACEngine.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/HMACEngine.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
@@ -153,6 +153,8 @@ protected:
|
||||
|
||||
private:
|
||||
HMACEngine();
|
||||
HMACEngine(const HMACEngine&);
|
||||
HMACEngine& operator = (const HMACEngine&);
|
||||
|
||||
Engine _engine;
|
||||
char* _ipad;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// LinearHashTable.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/LinearHashTable.h#11 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/LinearHashTable.h#13 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
@@ -86,40 +86,38 @@ public:
|
||||
typedef HashFunc Hash;
|
||||
typedef std::vector<Value> Bucket;
|
||||
typedef std::vector<Bucket> BucketVec;
|
||||
typedef typename Bucket::iterator BucketIterator;
|
||||
typedef typename BucketVec::iterator BucketVecIterator;
|
||||
|
||||
template <class VecIt, class BuckIt>
|
||||
class BasicConstIterator;
|
||||
|
||||
template <class VecIt, class BuckIt>
|
||||
class BasicIterator
|
||||
class ConstIterator
|
||||
{
|
||||
public:
|
||||
BasicIterator()
|
||||
ConstIterator()
|
||||
{
|
||||
}
|
||||
|
||||
BasicIterator(const VecIt& vecIt, const VecIt& endIt, const BuckIt& buckIt):
|
||||
ConstIterator(const BucketVecIterator& vecIt, const BucketVecIterator& endIt, const BucketIterator& buckIt):
|
||||
_vecIt(vecIt),
|
||||
_endIt(endIt),
|
||||
_buckIt(buckIt)
|
||||
{
|
||||
}
|
||||
|
||||
BasicIterator(const BasicIterator& it):
|
||||
ConstIterator(const ConstIterator& it):
|
||||
_vecIt(it._vecIt),
|
||||
_endIt(it._endIt),
|
||||
_buckIt(it._buckIt)
|
||||
{
|
||||
}
|
||||
|
||||
BasicIterator& operator = (const BasicIterator& it)
|
||||
ConstIterator& operator = (const ConstIterator& it)
|
||||
{
|
||||
BasicIterator tmp(it);
|
||||
ConstIterator tmp(it);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(BasicIterator& it)
|
||||
void swap(ConstIterator& it)
|
||||
{
|
||||
using std::swap;
|
||||
swap(_vecIt, it._vecIt);
|
||||
@@ -127,170 +125,120 @@ public:
|
||||
swap(_buckIt, it._buckIt);
|
||||
}
|
||||
|
||||
bool operator == (const BasicIterator& it) const
|
||||
bool operator == (const ConstIterator& it) const
|
||||
{
|
||||
return _vecIt == it._vecIt && (_vecIt == _endIt || _buckIt == it._buckIt);
|
||||
}
|
||||
|
||||
bool operator != (const BasicIterator& it) const
|
||||
bool operator != (const ConstIterator& it) const
|
||||
{
|
||||
return _vecIt != it._vecIt || (_vecIt != _endIt && _buckIt != it._buckIt);
|
||||
}
|
||||
|
||||
const typename Bucket::value_type& operator * () const
|
||||
{
|
||||
return *_buckIt;
|
||||
}
|
||||
|
||||
const typename Bucket::value_type* operator -> () const
|
||||
{
|
||||
return &*_buckIt;
|
||||
}
|
||||
|
||||
ConstIterator& operator ++ () // prefix
|
||||
{
|
||||
if (_vecIt != _endIt)
|
||||
{
|
||||
++_buckIt;
|
||||
while (_vecIt != _endIt && _buckIt == _vecIt->end())
|
||||
{
|
||||
++_vecIt;
|
||||
if (_vecIt != _endIt) _buckIt = _vecIt->begin();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConstIterator operator ++ (int) // postfix
|
||||
{
|
||||
ConstIterator tmp(*this);
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
protected:
|
||||
BucketVecIterator _vecIt;
|
||||
BucketVecIterator _endIt;
|
||||
BucketIterator _buckIt;
|
||||
|
||||
friend class LinearHashTable;
|
||||
};
|
||||
|
||||
class Iterator: public ConstIterator
|
||||
{
|
||||
public:
|
||||
Iterator()
|
||||
{
|
||||
}
|
||||
|
||||
Iterator(const BucketVecIterator& vecIt, const BucketVecIterator& endIt, const BucketIterator& buckIt):
|
||||
ConstIterator(vecIt, endIt, buckIt)
|
||||
{
|
||||
}
|
||||
|
||||
Iterator(const Iterator& it):
|
||||
ConstIterator(it)
|
||||
{
|
||||
}
|
||||
|
||||
Iterator& operator = (const Iterator& it)
|
||||
{
|
||||
Iterator tmp(it);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(Iterator& it)
|
||||
{
|
||||
ConstIterator::swap(it);
|
||||
}
|
||||
|
||||
typename Bucket::value_type& operator * ()
|
||||
{
|
||||
return *_buckIt;
|
||||
return *this->_buckIt;
|
||||
}
|
||||
|
||||
const typename Bucket::value_type& operator * () const
|
||||
{
|
||||
return *_buckIt;
|
||||
return *this->_buckIt;
|
||||
}
|
||||
|
||||
typename Bucket::value_type* operator -> ()
|
||||
{
|
||||
return &*_buckIt;
|
||||
return &*this->_buckIt;
|
||||
}
|
||||
|
||||
const typename Bucket::value_type* operator -> () const
|
||||
{
|
||||
return &*_buckIt;
|
||||
return &*this->_buckIt;
|
||||
}
|
||||
|
||||
BasicIterator& operator ++ () // prefix
|
||||
Iterator& operator ++ () // prefix
|
||||
{
|
||||
if (_vecIt != _endIt)
|
||||
{
|
||||
++_buckIt;
|
||||
while (_vecIt != _endIt && _buckIt == _vecIt->end())
|
||||
{
|
||||
++_vecIt;
|
||||
if (_vecIt != _endIt) _buckIt = _vecIt->begin();
|
||||
}
|
||||
}
|
||||
ConstIterator::operator ++ ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
BasicIterator operator ++ (int) // postfix
|
||||
Iterator operator ++ (int) // postfix
|
||||
{
|
||||
BasicIterator tmp(*this);
|
||||
Iterator tmp(*this);
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private:
|
||||
VecIt _vecIt;
|
||||
VecIt _endIt;
|
||||
BuckIt _buckIt;
|
||||
|
||||
friend class LinearHashTable;
|
||||
template <class, class> friend class BasicConstIterator;
|
||||
};
|
||||
|
||||
typedef BasicIterator<typename BucketVec::iterator, typename Bucket::iterator> Iterator;
|
||||
|
||||
template <class VecIt, class BuckIt>
|
||||
class BasicConstIterator
|
||||
{
|
||||
public:
|
||||
BasicConstIterator()
|
||||
{
|
||||
}
|
||||
|
||||
BasicConstIterator(const VecIt& vecIt, const VecIt& endIt, const BuckIt& buckIt):
|
||||
_vecIt(vecIt),
|
||||
_endIt(endIt),
|
||||
_buckIt(buckIt)
|
||||
{
|
||||
}
|
||||
|
||||
BasicConstIterator(const BasicConstIterator& it):
|
||||
_vecIt(it._vecIt),
|
||||
_endIt(it._endIt),
|
||||
_buckIt(it._buckIt)
|
||||
{
|
||||
}
|
||||
|
||||
BasicConstIterator(const Iterator& it):
|
||||
_vecIt(it._vecIt),
|
||||
_endIt(it._endIt),
|
||||
_buckIt(it._buckIt)
|
||||
{
|
||||
}
|
||||
|
||||
BasicConstIterator& operator = (const BasicConstIterator& it)
|
||||
{
|
||||
BasicConstIterator tmp(it);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BasicConstIterator& operator = (const Iterator& it)
|
||||
{
|
||||
BasicConstIterator tmp(it);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(BasicConstIterator& it)
|
||||
{
|
||||
using std::swap;
|
||||
swap(_vecIt, it._vecIt);
|
||||
swap(_endIt, it._endIt);
|
||||
swap(_buckIt, it._buckIt);
|
||||
}
|
||||
|
||||
bool operator == (const BasicConstIterator& it) const
|
||||
{
|
||||
return _vecIt == it._vecIt && (_vecIt == _endIt || _buckIt == it._buckIt);
|
||||
}
|
||||
|
||||
bool operator != (const BasicConstIterator& it) const
|
||||
{
|
||||
return _vecIt != it._vecIt || (_vecIt != _endIt && _buckIt != it._buckIt);
|
||||
}
|
||||
|
||||
const typename Bucket::value_type& operator * () const
|
||||
{
|
||||
return *_buckIt;
|
||||
}
|
||||
|
||||
const typename Bucket::value_type* operator -> () const
|
||||
{
|
||||
return &*_buckIt;
|
||||
}
|
||||
|
||||
BasicConstIterator& operator ++ () // prefix
|
||||
{
|
||||
if (_vecIt != _endIt)
|
||||
{
|
||||
++_buckIt;
|
||||
while (_vecIt != _endIt && _buckIt == _vecIt->end())
|
||||
{
|
||||
++_vecIt;
|
||||
if (_vecIt != _endIt) _buckIt = _vecIt->begin();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
BasicConstIterator operator ++ (int) // postfix
|
||||
{
|
||||
BasicConstIterator tmp(*this);
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private:
|
||||
VecIt _vecIt;
|
||||
VecIt _endIt;
|
||||
BuckIt _buckIt;
|
||||
|
||||
friend class LinearHashTable;
|
||||
};
|
||||
|
||||
typedef BasicConstIterator<typename BucketVec::const_iterator, typename Bucket::const_iterator> ConstIterator;
|
||||
|
||||
LinearHashTable(std::size_t initialReserve = 64):
|
||||
_split(0),
|
||||
_front(1),
|
||||
@@ -336,8 +284,8 @@ public:
|
||||
ConstIterator begin() const
|
||||
/// Returns an iterator pointing to the first entry, if one exists.
|
||||
{
|
||||
typename BucketVec::const_iterator it = _buckets.begin();
|
||||
typename BucketVec::const_iterator end = _buckets.end();
|
||||
BucketVecIterator it(_buckets.begin());
|
||||
BucketVecIterator end(_buckets.end());
|
||||
while (it != end && it->empty())
|
||||
{
|
||||
++it;
|
||||
@@ -357,8 +305,8 @@ public:
|
||||
Iterator begin()
|
||||
/// Returns an iterator pointing to the first entry, if one exists.
|
||||
{
|
||||
typename BucketVec::iterator it = _buckets.begin();
|
||||
typename BucketVec::iterator end = _buckets.end();
|
||||
BucketVecIterator it(_buckets.begin());
|
||||
BucketVecIterator end(_buckets.end());
|
||||
while (it != end && it->empty())
|
||||
{
|
||||
++it;
|
||||
@@ -379,8 +327,8 @@ public:
|
||||
/// Finds an entry in the table.
|
||||
{
|
||||
std::size_t addr = bucketAddress(value);
|
||||
typename BucketVec::const_iterator it = _buckets.begin() + addr;
|
||||
typename Bucket::const_iterator buckIt = std::find(it->begin(), it->end(), value);
|
||||
BucketVecIterator it(_buckets.begin() + addr);
|
||||
BucketIterator buckIt(std::find(it->begin(), it->end(), value));
|
||||
if (buckIt != it->end())
|
||||
return ConstIterator(it, _buckets.end(), buckIt);
|
||||
else
|
||||
@@ -391,8 +339,8 @@ public:
|
||||
/// Finds an entry in the table.
|
||||
{
|
||||
std::size_t addr = bucketAddress(value);
|
||||
typename BucketVec::iterator it = _buckets.begin() + addr;
|
||||
typename Bucket::iterator buckIt = std::find(it->begin(), it->end(), value);
|
||||
BucketVecIterator it(_buckets.begin() + addr);
|
||||
BucketIterator buckIt(std::find(it->begin(), it->end(), value));
|
||||
if (buckIt != it->end())
|
||||
return Iterator(it, _buckets.end(), buckIt);
|
||||
else
|
||||
@@ -418,8 +366,8 @@ public:
|
||||
{
|
||||
split();
|
||||
std::size_t addr = bucketAddress(value);
|
||||
typename BucketVec::iterator it = _buckets.begin() + addr;
|
||||
typename Bucket::iterator buckIt = std::find(it->begin(), it->end(), value);
|
||||
BucketVecIterator it(_buckets.begin() + addr);
|
||||
BucketIterator buckIt(std::find(it->begin(), it->end(), value));
|
||||
if (buckIt == it->end())
|
||||
{
|
||||
buckIt = it->insert(buckIt, value);
|
||||
@@ -491,7 +439,7 @@ protected:
|
||||
_buckets.push_back(tmp);
|
||||
_buckets[_split].swap(tmp);
|
||||
++_split;
|
||||
for (typename Bucket::iterator it = tmp.begin(); it != tmp.end(); ++it)
|
||||
for (BucketIterator it = tmp.begin(); it != tmp.end(); ++it)
|
||||
{
|
||||
using std::swap;
|
||||
std::size_t addr = bucketAddress(*it);
|
||||
@@ -511,7 +459,7 @@ protected:
|
||||
Bucket tmp;
|
||||
tmp.swap(_buckets.back());
|
||||
_buckets.pop_back();
|
||||
for (typename Bucket::iterator it = tmp.begin(); it != tmp.end(); ++it)
|
||||
for (BucketIterator it = tmp.begin(); it != tmp.end(); ++it)
|
||||
{
|
||||
using std::swap;
|
||||
std::size_t addr = bucketAddress(*it);
|
||||
@@ -528,7 +476,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
BucketVec _buckets;
|
||||
// Evil hack: _buckets must be mutable because both ConstIterator and Iterator hold
|
||||
// ordinary iterator's (not const_iterator's).
|
||||
mutable BucketVec _buckets;
|
||||
std::size_t _split;
|
||||
std::size_t _front;
|
||||
std::size_t _size;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MD2Engine.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/MD2Engine.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/MD2Engine.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
@@ -100,6 +100,9 @@ private:
|
||||
|
||||
Context _context;
|
||||
DigestEngine::Digest _digest;
|
||||
|
||||
MD2Engine(const MD2Engine&);
|
||||
MD2Engine& operator = (const MD2Engine&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MD4Engine.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/MD4Engine.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/MD4Engine.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
@@ -105,6 +105,9 @@ private:
|
||||
|
||||
Context _context;
|
||||
DigestEngine::Digest _digest;
|
||||
|
||||
MD4Engine(const MD4Engine&);
|
||||
MD4Engine& operator = (const MD4Engine&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MD5Engine.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/MD5Engine.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/MD5Engine.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
@@ -105,6 +105,9 @@ private:
|
||||
|
||||
Context _context;
|
||||
DigestEngine::Digest _digest;
|
||||
|
||||
MD5Engine(const MD5Engine&);
|
||||
MD5Engine& operator = (const MD5Engine&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Process_WIN32.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Process_WIN32.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Process_WIN32.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -64,6 +64,9 @@ public:
|
||||
private:
|
||||
HANDLE _hProcess;
|
||||
UInt32 _pid;
|
||||
|
||||
ProcessHandleImpl(const ProcessHandleImpl&);
|
||||
ProcessHandleImpl& operator = (const ProcessHandleImpl&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Process_WIN32U.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Process_WIN32U.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Process_WIN32U.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -64,6 +64,9 @@ public:
|
||||
private:
|
||||
HANDLE _hProcess;
|
||||
UInt32 _pid;
|
||||
|
||||
ProcessHandleImpl(const ProcessHandleImpl&);
|
||||
ProcessHandleImpl& operator = (const ProcessHandleImpl&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SHA1Engine.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SHA1Engine.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SHA1Engine.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
@@ -91,6 +91,9 @@ private:
|
||||
|
||||
Context _context;
|
||||
DigestEngine::Digest _digest;
|
||||
|
||||
SHA1Engine(const SHA1Engine&);
|
||||
SHA1Engine& operator = (const SHA1Engine&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedMemory.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory.h#5 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory.h#6 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
/// Default constructor creates an unmapped SharedMemory object.
|
||||
/// No clients can connect to an unmapped SharedMemory object.
|
||||
|
||||
SharedMemory(const std::string& name, std::size_t size, AccessMode mode, const void* addrHint = 0);
|
||||
SharedMemory(const std::string& name, std::size_t size, AccessMode mode, const void* addrHint = 0, bool server = true);
|
||||
/// Creates or connects to a shared memory object with the given name.
|
||||
///
|
||||
/// For maximum portability, name should be a valid Unix filename and not
|
||||
@@ -81,6 +81,10 @@ public:
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
///
|
||||
/// If server is set to false, the shared memory region will be unlinked
|
||||
/// by calling shm_unlink (on POSIX platforms) when the SharedMemory object is destroyed.
|
||||
/// The server parameter is ignored on Windows platforms.
|
||||
|
||||
SharedMemory(const File& file, AccessMode mode, const void* addrHint = 0);
|
||||
/// Maps the entire contents of file into a shared memory segment.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedMemoryImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory_DUMMY.h#4 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory_DUMMY.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -53,7 +53,7 @@ class Foundation_API SharedMemoryImpl: public RefCountedObject
|
||||
/// that do not have shared memory support.
|
||||
{
|
||||
public:
|
||||
SharedMemoryImpl(const std::string& id, std::size_t size, SharedMemory::AccessMode mode, const void* addr);
|
||||
SharedMemoryImpl(const std::string& id, std::size_t size, SharedMemory::AccessMode mode, const void* addr, bool server);
|
||||
/// Creates or connects to a shared memory object with the given name.
|
||||
///
|
||||
/// For maximum portability, name should be a valid Unix filename and not
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedMemoryImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory_POSIX.h#5 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory_POSIX.h#6 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -52,7 +52,7 @@ class Foundation_API SharedMemoryImpl: public RefCountedObject
|
||||
/// Shared memory implementation for POSIX platforms.
|
||||
{
|
||||
public:
|
||||
SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint);
|
||||
SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint, bool server);
|
||||
/// Creates or connects to a shared memory object with the given name.
|
||||
///
|
||||
/// For maximum portability, name should be a valid Unix filename and not
|
||||
@@ -62,6 +62,9 @@ public:
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
///
|
||||
/// If server is set to false, the shared memory region will be unlinked
|
||||
/// by calling shm_unlink when the SharedMemory object is destroyed.
|
||||
|
||||
SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void* addrHint);
|
||||
/// Maps the entire contents of file into a shared memory segment.
|
||||
@@ -101,6 +104,7 @@ private:
|
||||
SharedMemory::AccessMode _access;
|
||||
std::string _name;
|
||||
bool _fileMapped;
|
||||
bool _server;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedMemoryImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory_WIN32.h#4 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory_WIN32.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -52,7 +52,7 @@ class Foundation_API SharedMemoryImpl: public RefCountedObject
|
||||
/// Shared memory implementation for Windows platforms.
|
||||
{
|
||||
public:
|
||||
SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint);
|
||||
SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint, bool server);
|
||||
/// Creates or connects to a shared memory object with the given name.
|
||||
///
|
||||
/// For maximum portability, name should be a valid Unix filename and not
|
||||
|
@@ -49,7 +49,7 @@ namespace Poco {
|
||||
|
||||
class Foundation_API Stopwatch
|
||||
/// A simple facility to measure time intervals
|
||||
/// with (theoretical) microsecond resolution.
|
||||
/// with microsecond resolution.
|
||||
{
|
||||
public:
|
||||
Stopwatch();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// String.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/String.h#7 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/String.h#8 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -202,8 +202,8 @@ int icompare(
|
||||
It end1 = str.begin() + pos + n;
|
||||
while (it1 != end1 && it2 != end2)
|
||||
{
|
||||
typename S::value_type c1 = std::tolower(*it1);
|
||||
typename S::value_type c2 = std::tolower(*it2);
|
||||
typename S::value_type c1(std::tolower(*it1));
|
||||
typename S::value_type c2(std::tolower(*it2));
|
||||
if (c1 < c2)
|
||||
return -1;
|
||||
else if (c1 > c2)
|
||||
@@ -294,8 +294,8 @@ int icompare(
|
||||
typename S::const_iterator end = str.begin() + pos + n;
|
||||
while (it != end && *ptr)
|
||||
{
|
||||
typename S::value_type c1 = std::tolower(*it);
|
||||
typename S::value_type c2 = std::tolower(*ptr);
|
||||
typename S::value_type c1(std::tolower(*it));
|
||||
typename S::value_type c2(std::tolower(*ptr));
|
||||
if (c1 < c2)
|
||||
return -1;
|
||||
else if (c1 > c2)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Thread_WIN32.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Thread_WIN32.h#4 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Thread_WIN32.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -101,7 +101,7 @@ inline int ThreadImpl::getPriorityImpl() const
|
||||
|
||||
inline void ThreadImpl::sleepImpl(long milliseconds)
|
||||
{
|
||||
Sleep(milliseconds);
|
||||
Sleep(DWORD(milliseconds));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Timer.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Timer.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Timer.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -138,6 +138,9 @@ private:
|
||||
Event _done;
|
||||
AbstractTimerCallback* _pCallback;
|
||||
mutable FastMutex _mutex;
|
||||
|
||||
Timer(const Timer&);
|
||||
Timer& operator = (const Timer&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// UnufferedStreamBuf.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/UnbufferedStreamBuf.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/UnbufferedStreamBuf.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -169,13 +169,16 @@ private:
|
||||
return char_traits::eof();
|
||||
}
|
||||
|
||||
virtual int_type writeToDevice(char_type c)
|
||||
virtual int_type writeToDevice(char_type)
|
||||
{
|
||||
return char_traits::eof();
|
||||
}
|
||||
|
||||
int_type _pb;
|
||||
bool _ispb;
|
||||
|
||||
BasicUnbufferedStreamBuf(const BasicUnbufferedStreamBuf&);
|
||||
BasicUnbufferedStreamBuf& operator = (const BasicUnbufferedStreamBuf&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DynamicAny.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/DynamicAny.cpp#4 $
|
||||
// $Id: //poco/Main/Foundation/src/DynamicAny.cpp#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -35,7 +35,9 @@
|
||||
|
||||
|
||||
#include "Poco/DynamicAny.h"
|
||||
#include "Poco/DynamicStruct.h"
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -75,7 +77,187 @@ void DynamicAny::swap(DynamicAny& ptr)
|
||||
|
||||
const std::type_info& DynamicAny::type() const
|
||||
{
|
||||
return _pHolder->type();
|
||||
return _pHolder->type();
|
||||
}
|
||||
|
||||
|
||||
DynamicAny& DynamicAny::operator[](std::vector<DynamicAny>::size_type n)
|
||||
{
|
||||
DynamicAnyHolderImpl<std::vector<DynamicAny> >* pHolder = dynamic_cast<DynamicAnyHolderImpl<std::vector<DynamicAny> > *>(_pHolder);
|
||||
if (pHolder)
|
||||
return pHolder->operator[](n);
|
||||
else
|
||||
throw BadCastException();
|
||||
}
|
||||
|
||||
|
||||
const DynamicAny& DynamicAny::operator[](std::vector<DynamicAny>::size_type n) const
|
||||
{
|
||||
const DynamicAnyHolderImpl<std::vector<DynamicAny> >* pHolder = dynamic_cast<const DynamicAnyHolderImpl<std::vector<DynamicAny> > *>(_pHolder);
|
||||
if (pHolder)
|
||||
return pHolder->operator[](n);
|
||||
else
|
||||
throw BadCastException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
DynamicAny& DynamicAny::operator[](const std::string& name)
|
||||
{
|
||||
DynamicAnyHolderImpl<DynamicStruct>* pHolder = dynamic_cast<DynamicAnyHolderImpl<DynamicStruct> *>(_pHolder);
|
||||
if (pHolder)
|
||||
return pHolder->operator[](name);
|
||||
else
|
||||
throw BadCastException();
|
||||
}
|
||||
|
||||
|
||||
const DynamicAny& DynamicAny::operator[](const std::string& name) const
|
||||
{
|
||||
const DynamicAnyHolderImpl<DynamicStruct>* pHolder = dynamic_cast<const DynamicAnyHolderImpl<DynamicStruct>* >(_pHolder);
|
||||
if (pHolder)
|
||||
return pHolder->operator[](name);
|
||||
else
|
||||
throw BadCastException();
|
||||
}
|
||||
|
||||
|
||||
DynamicAny DynamicAny::parse(const std::string& val)
|
||||
{
|
||||
std::string::size_type t = 0;
|
||||
return parse(val, t);
|
||||
}
|
||||
|
||||
|
||||
DynamicAny DynamicAny::parse(const std::string& val, std::string::size_type& pos)
|
||||
{
|
||||
// { -> an Object==DynamicStruct
|
||||
// [ -> an array
|
||||
// '/" -> a string (strip '/")
|
||||
// other: also treat as string
|
||||
skipWhiteSpace(val, pos);
|
||||
if (pos < val.size())
|
||||
{
|
||||
switch(val[pos])
|
||||
{
|
||||
case '{':
|
||||
return parseObject(val, pos);
|
||||
case '[':
|
||||
return parseArray(val, pos);
|
||||
default:
|
||||
return parseString(val, pos);
|
||||
}
|
||||
}
|
||||
std::string empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
DynamicAny DynamicAny::parseObject(const std::string& val, std::string::size_type& pos)
|
||||
{
|
||||
poco_assert_dbg (val[pos] == '{');
|
||||
++pos;
|
||||
skipWhiteSpace(val, pos);
|
||||
DynamicStruct aStruct;
|
||||
while(val[pos] != '}' && pos < val.size())
|
||||
{
|
||||
std::string key = parseString(val, pos);
|
||||
skipWhiteSpace(val, pos);
|
||||
if (val[pos] != ':')
|
||||
throw DataFormatException("Incorrect object, must contain: key : value pairs");
|
||||
++pos; // skip past :
|
||||
DynamicAny value = parse(val, pos);
|
||||
aStruct.insert(key, value);
|
||||
skipWhiteSpace(val, pos);
|
||||
if (val[pos] == ',')
|
||||
{
|
||||
++pos;
|
||||
skipWhiteSpace(val, pos);
|
||||
}
|
||||
}
|
||||
if (val[pos] != '}')
|
||||
throw DataFormatException("Unterminated object");
|
||||
++pos;
|
||||
return aStruct;
|
||||
}
|
||||
|
||||
|
||||
DynamicAny DynamicAny::parseArray(const std::string& val, std::string::size_type& pos)
|
||||
{
|
||||
poco_assert_dbg (val[pos] == '[');
|
||||
++pos;
|
||||
skipWhiteSpace(val, pos);
|
||||
std::vector<DynamicAny> result;
|
||||
while(val[pos] != ']' && pos < val.size())
|
||||
{
|
||||
result.push_back(parse(val, pos));
|
||||
skipWhiteSpace(val, pos);
|
||||
if (val[pos] == ',')
|
||||
{
|
||||
++pos;
|
||||
skipWhiteSpace(val, pos);
|
||||
}
|
||||
}
|
||||
if (val[pos] != ']')
|
||||
throw DataFormatException("Unterminated array");
|
||||
++pos;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::string DynamicAny::parseString(const std::string& val, std::string::size_type& pos)
|
||||
{
|
||||
static const std::string STR_STOP("'\"");
|
||||
static const std::string OTHER_STOP(" ,]}"); // we stop at space, ',', ']' or '}'
|
||||
|
||||
bool inString = false;
|
||||
//skip optional ' "
|
||||
if (val[pos] == '\'' || val[pos] == '"')
|
||||
{
|
||||
inString = true;
|
||||
++pos;
|
||||
}
|
||||
|
||||
|
||||
std::string::size_type stop = std::string::npos;
|
||||
if (inString)
|
||||
{
|
||||
stop = val.find_first_of(STR_STOP, pos);
|
||||
if (stop == std::string::npos)
|
||||
throw DataFormatException("Unterminated string");
|
||||
}
|
||||
else
|
||||
{
|
||||
// we stop at space, ',', ']' or '}' or end of string
|
||||
stop = val.find_first_of(OTHER_STOP, pos);
|
||||
if (stop == std::string::npos)
|
||||
stop = val.size();
|
||||
|
||||
std::string::size_type safeCheck = val.find_first_of(STR_STOP, pos);
|
||||
if (safeCheck != std::string::npos && safeCheck < stop)
|
||||
throw DataFormatException("Misplaced string termination char found");
|
||||
|
||||
}
|
||||
|
||||
// stop now points to the last char to be not included
|
||||
std::string result = val.substr(pos, stop - pos);
|
||||
++stop; // point past '/"
|
||||
pos = stop;
|
||||
return result;
|
||||
}
|
||||
|
||||
void DynamicAny::skipWhiteSpace(const std::string& val, std::string::size_type& pos)
|
||||
{
|
||||
while (std::isspace(val[pos]))
|
||||
++pos;
|
||||
}
|
||||
|
||||
|
||||
std::string DynamicAny::toString(const DynamicAny& any)
|
||||
{
|
||||
std::string res;
|
||||
appendJSONString(res, any);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DynamicAnyHolder.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/DynamicAnyHolder.cpp#2 $
|
||||
// $Id: //poco/Main/Foundation/src/DynamicAnyHolder.cpp#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
|
||||
#include "Poco/DynamicAnyHolder.h"
|
||||
#include "Poco/DynamicAny.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -50,4 +51,18 @@ DynamicAnyHolder::~DynamicAnyHolder()
|
||||
}
|
||||
|
||||
|
||||
void appendJSONString(std::string& val, const DynamicAny& any)
|
||||
{
|
||||
bool isJsonString = (any.type() == typeid(std::string) || any.type() == typeid(char) || any.type() == typeid(Poco::DateTime) || any.type() == typeid(Poco::LocalDateTime));
|
||||
if (isJsonString)
|
||||
{
|
||||
val.append(1, '\'');
|
||||
}
|
||||
val.append(any.convert<std::string>());
|
||||
if (isJsonString)
|
||||
{
|
||||
val.append(1, '\'');
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Poco
|
||||
|
81
Foundation/src/DynamicStruct.cpp
Normal file
81
Foundation/src/DynamicStruct.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// DynamicStruct.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/DynamicStruct.cpp#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
// Module: DynamicStruct
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/DynamicStruct.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
DynamicStruct::DynamicStruct():
|
||||
_data()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DynamicStruct::DynamicStruct(const Data& d):
|
||||
_data(d)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DynamicStruct::~DynamicStruct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const DynamicAny& DynamicStruct::operator[](const std::string& name) const
|
||||
{
|
||||
ConstIterator it = find(name);
|
||||
if (it == end())
|
||||
throw NotFoundException(name);
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
std::set<std::string> DynamicStruct::members() const
|
||||
{
|
||||
std::set<std::string> keys;
|
||||
ConstIterator it = begin();
|
||||
ConstIterator itEnd = end();
|
||||
for (; it != itEnd; ++it)
|
||||
keys.insert(it->first);
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco::Poco
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Glob.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/Glob.cpp#6 $
|
||||
// $Id: //poco/Main/Foundation/src/Glob.cpp#7 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@@ -219,7 +219,7 @@ void Glob::collect(const Path& pathPattern, const Path& base, const Path& curren
|
||||
else
|
||||
{
|
||||
p.setFileName(name);
|
||||
if (File(p).isDirectory())
|
||||
if (isDirectory(p, (options & GLOB_FOLLOW_SYMLINKS) != 0))
|
||||
{
|
||||
p.makeDirectory();
|
||||
files.insert(p.toString());
|
||||
@@ -239,4 +239,27 @@ void Glob::collect(const Path& pathPattern, const Path& base, const Path& curren
|
||||
}
|
||||
|
||||
|
||||
bool Glob::isDirectory(const Path& path, bool followSymlink)
|
||||
{
|
||||
File f(path);
|
||||
if (f.isDirectory())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (followSymlink && f.isLink())
|
||||
{
|
||||
try
|
||||
{
|
||||
// Test if link resolves to a directory.
|
||||
DirectoryIterator it(f);
|
||||
return true;
|
||||
}
|
||||
catch (Exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MemoryPool.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/MemoryPool.cpp#6 $
|
||||
// $Id: //poco/Main/Foundation/src/MemoryPool.cpp#7 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -47,6 +47,7 @@ MemoryPool::MemoryPool(std::size_t blockSize, int preAlloc, int maxAlloc):
|
||||
_allocated(preAlloc)
|
||||
{
|
||||
poco_assert (maxAlloc == 0 || maxAlloc >= preAlloc);
|
||||
poco_assert (preAlloc >= 0 && maxAlloc >= 0);
|
||||
|
||||
int r = BLOCK_RESERVE;
|
||||
if (preAlloc > r)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedMemory.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory.cpp#6 $
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory.cpp#7 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -60,8 +60,8 @@ SharedMemory::SharedMemory():
|
||||
}
|
||||
|
||||
|
||||
SharedMemory::SharedMemory(const std::string& name, std::size_t size, AccessMode mode, const void* addrHint):
|
||||
_pImpl(new SharedMemoryImpl(name, size, mode, addrHint))
|
||||
SharedMemory::SharedMemory(const std::string& name, std::size_t size, AccessMode mode, const void* addrHint, bool server):
|
||||
_pImpl(new SharedMemoryImpl(name, size, mode, addrHint, server))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedMemoryImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory_DUMMY.cpp#3 $
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory_DUMMY.cpp#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -40,7 +40,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
SharedMemoryImpl::SharedMemoryImpl(const std::string&, std::size_t, SharedMemory::AccessMode, const void*)
|
||||
SharedMemoryImpl::SharedMemoryImpl(const std::string&, std::size_t, SharedMemory::AccessMode, const void*, bool)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedMemoryImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory_POSIX.cpp#9 $
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory_POSIX.cpp#10 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -47,13 +47,14 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint):
|
||||
SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint, bool server):
|
||||
_size(size),
|
||||
_fd(-1),
|
||||
_address(0),
|
||||
_access(mode),
|
||||
_name("/"),
|
||||
_fileMapped(false)
|
||||
_fileMapped(false),
|
||||
_server(server)
|
||||
{
|
||||
#if POCO_OS == POCO_OS_HPUX
|
||||
_name.append("tmp/");
|
||||
@@ -90,7 +91,8 @@ SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessM
|
||||
_address(0),
|
||||
_access(mode),
|
||||
_name(file.path()),
|
||||
_fileMapped(true)
|
||||
_fileMapped(true),
|
||||
_server(false)
|
||||
{
|
||||
if (!file.exists() || !file.isFile())
|
||||
throw FileNotFoundException(file.path());
|
||||
@@ -144,7 +146,7 @@ void SharedMemoryImpl::close()
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
}
|
||||
if (!_fileMapped)
|
||||
if (!_fileMapped && _server)
|
||||
{
|
||||
::shm_unlink(_name.c_str());
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedMemoryImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory_WIN32.cpp#6 $
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory_WIN32.cpp#7 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
@@ -46,7 +46,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void*):
|
||||
SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void*, bool):
|
||||
_name(name),
|
||||
_memHandle(INVALID_HANDLE_VALUE),
|
||||
_fileHandle(INVALID_HANDLE_VALUE),
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// UUIDGenerator.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/UUIDGenerator.cpp#18 $
|
||||
// $Id: //poco/Main/Foundation/src/UUIDGenerator.cpp#19 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: UUID
|
||||
@@ -202,6 +202,7 @@ void UUIDGenerator::getNode()
|
||||
std::memcpy(_node, pAdapter->Address, pAdapter->AddressLength);
|
||||
found = true;
|
||||
}
|
||||
pAdapter = pAdapter->Next;
|
||||
}
|
||||
}
|
||||
else throw SystemException("cannot get network adapter list");
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// pocomsg.mc[.h]
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/pocomsg.h#26 $
|
||||
// $Id: //poco/Main/Foundation/src/pocomsg.mc#7 $
|
||||
//
|
||||
// The Poco message source/header file.
|
||||
//
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DynamicAnyTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.cpp#9 $
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.cpp#11 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/DynamicAny.h"
|
||||
#include "Poco/Bugcheck.h"
|
||||
#include "Poco/DynamicStruct.h"
|
||||
|
||||
|
||||
using namespace Poco;
|
||||
@@ -1221,6 +1222,534 @@ void DynamicAnyTest::testCtor()
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testIsStruct()
|
||||
{
|
||||
std::string s1("string");
|
||||
Poco::Int8 s2(-23);
|
||||
Poco::Int16 s3(-33);
|
||||
Poco::Int32 s4(-388);
|
||||
Poco::Int64 s5(-23823838);
|
||||
Poco::UInt8 s6(32);
|
||||
Poco::UInt16 s7(16000);
|
||||
Poco::UInt32 s8(334234);
|
||||
Poco::UInt64 s9(2328328382);
|
||||
float s10(13.333f);
|
||||
double s11(13.555);
|
||||
bool s12(true);
|
||||
char s13('c');
|
||||
long s14(232323);
|
||||
unsigned long s15(21233232);
|
||||
std::vector<DynamicAny> s16;
|
||||
DynamicStruct s17;
|
||||
|
||||
DynamicAny d1(s1);
|
||||
DynamicAny d2(s2);
|
||||
DynamicAny d3(s3);
|
||||
DynamicAny d4(s4);
|
||||
DynamicAny d5(s5);
|
||||
DynamicAny d6(s6);
|
||||
DynamicAny d7(s7);
|
||||
DynamicAny d8(s8);
|
||||
DynamicAny d9(s9);
|
||||
DynamicAny d10(s10);
|
||||
DynamicAny d11(s11);
|
||||
DynamicAny d12(s12);
|
||||
DynamicAny d13(s13);
|
||||
DynamicAny d14(s14);
|
||||
DynamicAny d15(s15);
|
||||
DynamicAny d16(s16);
|
||||
DynamicAny d17(s17);
|
||||
|
||||
assert (!d1.isStruct());
|
||||
assert (!d2.isStruct());
|
||||
assert (!d3.isStruct());
|
||||
assert (!d4.isStruct());
|
||||
assert (!d5.isStruct());
|
||||
assert (!d6.isStruct());
|
||||
assert (!d7.isStruct());
|
||||
assert (!d8.isStruct());
|
||||
assert (!d9.isStruct());
|
||||
assert (!d10.isStruct());
|
||||
assert (!d11.isStruct());
|
||||
assert (!d12.isStruct());
|
||||
assert (!d13.isStruct());
|
||||
assert (!d14.isStruct());
|
||||
assert (!d15.isStruct());
|
||||
assert (!d16.isStruct());
|
||||
assert (d17.isStruct());
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testIsArray()
|
||||
{
|
||||
std::string s1("string");
|
||||
Poco::Int8 s2(-23);
|
||||
Poco::Int16 s3(-33);
|
||||
Poco::Int32 s4(-388);
|
||||
Poco::Int64 s5(-23823838);
|
||||
Poco::UInt8 s6(32);
|
||||
Poco::UInt16 s7(16000);
|
||||
Poco::UInt32 s8(334234);
|
||||
Poco::UInt64 s9(2328328382);
|
||||
float s10(13.333f);
|
||||
double s11(13.555);
|
||||
bool s12(true);
|
||||
char s13('c');
|
||||
long s14(232323);
|
||||
unsigned long s15(21233232);
|
||||
std::vector<DynamicAny> s16;
|
||||
DynamicStruct s17;
|
||||
|
||||
DynamicAny d1(s1);
|
||||
DynamicAny d2(s2);
|
||||
DynamicAny d3(s3);
|
||||
DynamicAny d4(s4);
|
||||
DynamicAny d5(s5);
|
||||
DynamicAny d6(s6);
|
||||
DynamicAny d7(s7);
|
||||
DynamicAny d8(s8);
|
||||
DynamicAny d9(s9);
|
||||
DynamicAny d10(s10);
|
||||
DynamicAny d11(s11);
|
||||
DynamicAny d12(s12);
|
||||
DynamicAny d13(s13);
|
||||
DynamicAny d14(s14);
|
||||
DynamicAny d15(s15);
|
||||
DynamicAny d16(s16);
|
||||
DynamicAny d17(s17);
|
||||
|
||||
assert (!d1.isArray());
|
||||
assert (!d2.isArray());
|
||||
assert (!d3.isArray());
|
||||
assert (!d4.isArray());
|
||||
assert (!d5.isArray());
|
||||
assert (!d6.isArray());
|
||||
assert (!d7.isArray());
|
||||
assert (!d8.isArray());
|
||||
assert (!d9.isArray());
|
||||
assert (!d10.isArray());
|
||||
assert (!d11.isArray());
|
||||
assert (!d12.isArray());
|
||||
assert (!d13.isArray());
|
||||
assert (!d14.isArray());
|
||||
assert (!d15.isArray());
|
||||
assert (d16.isArray());
|
||||
assert (!d17.isArray());
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testArrayIdxOperator()
|
||||
{
|
||||
std::string s1("string");
|
||||
Poco::Int8 s2(-23);
|
||||
Poco::Int16 s3(-33);
|
||||
Poco::Int32 s4(-388);
|
||||
Poco::Int64 s5(-23823838);
|
||||
Poco::UInt8 s6(32);
|
||||
Poco::UInt16 s7(16000);
|
||||
Poco::UInt32 s8(334234);
|
||||
Poco::UInt64 s9(2328328382);
|
||||
float s10(13.333f);
|
||||
double s11(13.555);
|
||||
bool s12(true);
|
||||
char s13('c');
|
||||
long s14(232323);
|
||||
unsigned long s15(21233232);
|
||||
std::vector<DynamicAny> s16;
|
||||
s16.push_back(s1);
|
||||
s16.push_back(s2);
|
||||
DynamicStruct s17;
|
||||
|
||||
DynamicAny d1(s1);
|
||||
DynamicAny d2(s2);
|
||||
DynamicAny d3(s3);
|
||||
DynamicAny d4(s4);
|
||||
DynamicAny d5(s5);
|
||||
DynamicAny d6(s6);
|
||||
DynamicAny d7(s7);
|
||||
DynamicAny d8(s8);
|
||||
DynamicAny d9(s9);
|
||||
DynamicAny d10(s10);
|
||||
DynamicAny d11(s11);
|
||||
DynamicAny d12(s12);
|
||||
DynamicAny d13(s13);
|
||||
DynamicAny d14(s14);
|
||||
DynamicAny d15(s15);
|
||||
DynamicAny d16(s16);
|
||||
DynamicAny d17(s17);
|
||||
|
||||
testGetIdxMustThrow(d1, 0);
|
||||
testGetIdxMustThrow(d2, 0);
|
||||
testGetIdxMustThrow(d3, 0);
|
||||
testGetIdxMustThrow(d4, 0);
|
||||
testGetIdxMustThrow(d5, 0);
|
||||
testGetIdxMustThrow(d6, 0);
|
||||
testGetIdxMustThrow(d7, 0);
|
||||
testGetIdxMustThrow(d8, 0);
|
||||
testGetIdxMustThrow(d9, 0);
|
||||
testGetIdxMustThrow(d10, 0);
|
||||
testGetIdxMustThrow(d11, 0);
|
||||
testGetIdxMustThrow(d12, 0);
|
||||
testGetIdxMustThrow(d13, 0);
|
||||
testGetIdxMustThrow(d14, 0);
|
||||
testGetIdxMustThrow(d15, 0);
|
||||
testGetIdx(d16, 0, s1);
|
||||
testGetIdx(d16, 1, s2);
|
||||
testGetIdxMustThrow(d17, 0);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testDynamicStructBasics()
|
||||
{
|
||||
DynamicStruct aStruct;
|
||||
assert (aStruct.empty());
|
||||
assert (aStruct.size() == 0);
|
||||
assert (aStruct.members().empty());
|
||||
|
||||
aStruct.insert("First Name", "Little");
|
||||
assert (!aStruct.empty());
|
||||
assert (aStruct.size() == 1);
|
||||
assert (*(aStruct.members().begin()) == "First Name");
|
||||
assert (aStruct["First Name"] == "Little");
|
||||
aStruct.insert("Last Name", "POCO");
|
||||
assert (aStruct.members().size() == 2);
|
||||
aStruct.erase("First Name");
|
||||
assert (aStruct.size() == 1);
|
||||
assert (*(aStruct.members().begin()) == "Last Name");
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testDynamicStruct()
|
||||
{
|
||||
DynamicStruct aStruct;
|
||||
aStruct["First Name"] = "Junior";
|
||||
aStruct["Last Name"] = "POCO";
|
||||
DynamicAny a1(aStruct);
|
||||
assert (a1["First Name"] == "Junior");
|
||||
assert (a1["Last Name"] == "POCO");
|
||||
a1["First Name"] = "Senior";
|
||||
assert (a1["First Name"] == "Senior");
|
||||
testGetIdxMustThrow(a1, 0);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testArrayToString()
|
||||
{
|
||||
std::string s1("string");
|
||||
Poco::Int8 s2(23);
|
||||
std::vector<DynamicAny> s16;
|
||||
s16.push_back(s1);
|
||||
s16.push_back(s2);
|
||||
DynamicAny a1(s16);
|
||||
std::string res = a1.convert<std::string>();
|
||||
std::string expected("[ 'string', 23 ]");
|
||||
assert (res == expected);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testStructToString()
|
||||
{
|
||||
DynamicStruct aStruct;
|
||||
aStruct["First Name"] = "Junior";
|
||||
aStruct["Last Name"] = "POCO";
|
||||
aStruct["Age"] = 1;
|
||||
DynamicAny a1(aStruct);
|
||||
std::string res = a1.convert<std::string>();
|
||||
std::string expected = "{ 'Age' : 1, 'First Name' : 'Junior', 'Last Name' : 'POCO' }";
|
||||
;
|
||||
assert (res == expected);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testArrayOfStructsToString()
|
||||
{
|
||||
std::vector<DynamicAny> s16;
|
||||
DynamicStruct aStruct;
|
||||
aStruct["First Name"] = "Junior";
|
||||
aStruct["Last Name"] = "POCO";
|
||||
aStruct["Age"] = 1;
|
||||
s16.push_back(aStruct);
|
||||
aStruct["First Name"] = "Senior";
|
||||
aStruct["Last Name"] = "POCO";
|
||||
aStruct["Age"] = 100;
|
||||
s16.push_back(aStruct);
|
||||
std::vector<DynamicAny> s16Cpy = s16;
|
||||
// recursive arrays!
|
||||
s16Cpy.push_back(s16);
|
||||
s16.push_back(s16Cpy);
|
||||
DynamicAny a1(s16);
|
||||
std::string res = a1.convert<std::string>();
|
||||
std::string expected = "[ "
|
||||
"{ 'Age' : 1, 'First Name' : 'Junior', 'Last Name' : 'POCO' }, "
|
||||
"{ 'Age' : 100, 'First Name' : 'Senior', 'Last Name' : 'POCO' }, "
|
||||
"[ "
|
||||
"{ 'Age' : 1, 'First Name' : 'Junior', 'Last Name' : 'POCO' }, "
|
||||
"{ 'Age' : 100, 'First Name' : 'Senior', 'Last Name' : 'POCO' }, "
|
||||
"[ "
|
||||
"{ 'Age' : 1, 'First Name' : 'Junior', 'Last Name' : 'POCO' }, "
|
||||
"{ 'Age' : 100, 'First Name' : 'Senior', 'Last Name' : 'POCO' } "
|
||||
"] ] ]";
|
||||
|
||||
assert (res == expected);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testStructWithArraysToString()
|
||||
{
|
||||
std::string s1("string");
|
||||
Poco::Int8 s2(23);
|
||||
std::vector<DynamicAny> s16;
|
||||
s16.push_back(s1);
|
||||
s16.push_back(s2);
|
||||
DynamicAny a1(s16);
|
||||
DynamicStruct addr;
|
||||
addr["Number"] = 4;
|
||||
addr["Street"] = "Unknown";
|
||||
addr["Country"] = "Carinthia";
|
||||
DynamicStruct aStruct;
|
||||
aStruct["First Name"] = "Junior";
|
||||
aStruct["Last Name"] = a1;
|
||||
aStruct["Age"] = 1;
|
||||
aStruct["Address"] = addr;
|
||||
DynamicAny a2(aStruct);
|
||||
std::string res = a2.convert<std::string>();
|
||||
std::string expected = "{ 'Address' : { 'Country' : 'Carinthia', 'Number' : 4, 'Street' : 'Unknown' }, "
|
||||
"'Age' : 1, 'First Name' : 'Junior', 'Last Name' : [ 'string', 23 ] }";
|
||||
|
||||
assert (res == expected);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testJSONDeserializeString()
|
||||
{
|
||||
DynamicAny a("test");
|
||||
std::string tst = DynamicAny::toString(a);
|
||||
DynamicAny b = DynamicAny::parse(tst);
|
||||
assert (b.convert<std::string>() == "test");
|
||||
|
||||
DynamicAny c('c');
|
||||
std::string tst2 = DynamicAny::toString(c);
|
||||
DynamicAny b2 = DynamicAny::parse(tst2);
|
||||
char cc = b2.convert<char>();
|
||||
assert (cc == 'c');
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testJSONDeserializePrimitives()
|
||||
{
|
||||
Poco::Int8 i8(-12);
|
||||
Poco::UInt16 u16(2345);
|
||||
Poco::Int32 i32(-24343);
|
||||
Poco::UInt64 u64(1234567890);
|
||||
u64 *= u64;
|
||||
bool b = false;
|
||||
float f = 3.1415f;
|
||||
double d = 3.1415;
|
||||
|
||||
std::string s8 = DynamicAny::toString(i8);
|
||||
std::string s16 = DynamicAny::toString(u16);
|
||||
std::string s32 = DynamicAny::toString(i32);
|
||||
std::string s64 = DynamicAny::toString(u64);
|
||||
std::string sb = DynamicAny::toString(b);
|
||||
std::string sf = DynamicAny::toString(f);
|
||||
std::string sd = DynamicAny::toString(d);
|
||||
DynamicAny a8 = DynamicAny::parse(s8);
|
||||
DynamicAny a16 = DynamicAny::parse(s16);
|
||||
DynamicAny a32 = DynamicAny::parse(s32);
|
||||
DynamicAny a64 = DynamicAny::parse(s64);
|
||||
DynamicAny ab = DynamicAny::parse(sb);
|
||||
DynamicAny af = DynamicAny::parse(sf);
|
||||
DynamicAny ad = DynamicAny::parse(sd);
|
||||
assert (a8 == i8);
|
||||
assert (a16 == u16);
|
||||
assert (a32 == i32);
|
||||
assert (a64 == u64);
|
||||
assert (ab == b);
|
||||
assert (af == f);
|
||||
assert (ad == d);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testJSONDeserializeArray()
|
||||
{
|
||||
Poco::Int8 i8(-12);
|
||||
Poco::UInt16 u16(2345);
|
||||
Poco::Int32 i32(-24343);
|
||||
Poco::UInt64 u64(1234567890);
|
||||
u64 *= u64;
|
||||
bool b = false;
|
||||
float f = 3.1415f;
|
||||
double d = 3.1415;
|
||||
std::string s("test string");
|
||||
char c('x');
|
||||
std::vector<DynamicAny> aVec;
|
||||
aVec.push_back(i8);
|
||||
aVec.push_back(u16);
|
||||
aVec.push_back(i32);
|
||||
aVec.push_back(u64);
|
||||
aVec.push_back(b);
|
||||
aVec.push_back(f);
|
||||
aVec.push_back(d);
|
||||
aVec.push_back(s);
|
||||
aVec.push_back(c);
|
||||
|
||||
std::string sVec = DynamicAny::toString(aVec);
|
||||
DynamicAny a = DynamicAny::parse(sVec);
|
||||
assert (a[0] == i8);
|
||||
assert (a[1] == u16);
|
||||
assert (a[2] == i32);
|
||||
assert (a[3] == u64);
|
||||
assert (a[4] == b);
|
||||
assert (a[5] == f);
|
||||
assert (a[6] == d);
|
||||
assert (a[7] == s);
|
||||
assert (a[8] == c);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testJSONDeserializeComplex()
|
||||
{
|
||||
Poco::Int8 i8(-12);
|
||||
Poco::UInt16 u16(2345);
|
||||
Poco::Int32 i32(-24343);
|
||||
Poco::UInt64 u64(1234567890);
|
||||
u64 *= u64;
|
||||
bool b = false;
|
||||
float f = 3.1415f;
|
||||
double d = 3.1415;
|
||||
std::string s("test string");
|
||||
char c('x');
|
||||
DynamicStruct aStr;
|
||||
aStr["i8"] = i8;
|
||||
aStr["u16"] = u16;
|
||||
aStr["i32"] = i32;
|
||||
aStr["u64"] = u64;
|
||||
aStr["b"] = b;
|
||||
aStr["f"] = f;
|
||||
aStr["d"] = d;
|
||||
aStr["s"] = s;
|
||||
aStr["c"] = c;
|
||||
std::vector<DynamicAny> aVec;
|
||||
aVec.push_back(i8);
|
||||
aVec.push_back(u16);
|
||||
aVec.push_back(i32);
|
||||
aVec.push_back(u64);
|
||||
aVec.push_back(b);
|
||||
aVec.push_back(f);
|
||||
aVec.push_back(d);
|
||||
aVec.push_back(s);
|
||||
aVec.push_back(c);
|
||||
aVec.push_back(aStr);
|
||||
aStr["vec"] = aVec;
|
||||
|
||||
std::string sStr = DynamicAny::toString(aStr);
|
||||
DynamicAny a = DynamicAny::parse(sStr);
|
||||
assert (a.isStruct());
|
||||
assert (aStr["i8"] == i8);
|
||||
assert (aStr["u16"] == u16);
|
||||
assert (aStr["i32"] == i32);
|
||||
assert (aStr["u64"] == u64);
|
||||
assert (aStr["b"] == b);
|
||||
assert (aStr["f"] == f);
|
||||
assert (aStr["d"] == d);
|
||||
assert (aStr["s"] == s);
|
||||
assert (aStr["c"] == c);
|
||||
DynamicAny vecRet = a["vec"];
|
||||
assert (vecRet.isArray());
|
||||
assert (vecRet[0] == i8);
|
||||
assert (vecRet[1] == u16);
|
||||
assert (vecRet[2] == i32);
|
||||
assert (vecRet[3] == u64);
|
||||
assert (vecRet[4] == b);
|
||||
assert (vecRet[5] == f);
|
||||
assert (vecRet[6] == d);
|
||||
assert (vecRet[7] == s);
|
||||
assert (vecRet[8] == c);
|
||||
DynamicAny strRet = vecRet[9];
|
||||
assert (strRet.isStruct());
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testJSONDeserializeStruct()
|
||||
{
|
||||
Poco::Int8 i8(-12);
|
||||
Poco::UInt16 u16(2345);
|
||||
Poco::Int32 i32(-24343);
|
||||
Poco::UInt64 u64(1234567890);
|
||||
u64 *= u64;
|
||||
bool b = false;
|
||||
float f = 3.1415f;
|
||||
double d = 3.1415;
|
||||
std::string s("test string");
|
||||
char c('x');
|
||||
DynamicStruct aStr;
|
||||
aStr["i8"] = i8;
|
||||
aStr["u16"] = u16;
|
||||
aStr["i32"] = i32;
|
||||
aStr["u64"] = u64;
|
||||
aStr["b"] = b;
|
||||
aStr["f"] = f;
|
||||
aStr["d"] = d;
|
||||
aStr["s"] = s;
|
||||
aStr["c"] = c;
|
||||
|
||||
std::string sStr = DynamicAny::toString(aStr);
|
||||
DynamicAny a = DynamicAny::parse(sStr);
|
||||
assert (aStr["i8"] == i8);
|
||||
assert (aStr["u16"] == u16);
|
||||
assert (aStr["i32"] == i32);
|
||||
assert (aStr["u64"] == u64);
|
||||
assert (aStr["b"] == b);
|
||||
assert (aStr["f"] == f);
|
||||
assert (aStr["d"] == d);
|
||||
assert (aStr["s"] == s);
|
||||
assert (aStr["c"] == c);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testDate()
|
||||
{
|
||||
Poco::DateTime dtNow(2007, 3, 13, 8, 12, 15);
|
||||
|
||||
Poco::Timestamp tsNow = dtNow.timestamp();
|
||||
Poco::LocalDateTime ldtNow(dtNow.timestamp());
|
||||
DynamicAny dt(dtNow);
|
||||
DynamicAny ts(tsNow);
|
||||
DynamicAny ldt(ldtNow);
|
||||
DynamicAny dtStr(dt.convert<std::string>());
|
||||
DynamicAny tsStr(ts.convert<std::string>());
|
||||
DynamicAny ldtStr(ldt.convert<std::string>());
|
||||
DateTime dtRes = dtStr.convert<DateTime>();
|
||||
LocalDateTime ldtRes = ldtStr.convert<LocalDateTime>();
|
||||
Timestamp tsRes = tsStr.convert<Timestamp>();
|
||||
assert (dtNow == dtRes);
|
||||
assert (ldtNow == ldtRes);
|
||||
assert (tsNow == tsRes);
|
||||
}
|
||||
|
||||
void DynamicAnyTest::testGetIdxMustThrow(DynamicAny& a1, std::vector<DynamicAny>::size_type n)
|
||||
{
|
||||
try
|
||||
{
|
||||
DynamicAny& val1 = a1[n];
|
||||
fail("bad cast - must throw");
|
||||
}
|
||||
catch (Poco::BadCastException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
const DynamicAny& c1 = a1;
|
||||
const DynamicAny& cval1 = c1[n];
|
||||
fail("bad const cast - must throw");
|
||||
}
|
||||
catch (Poco::BadCastException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::setUp()
|
||||
{
|
||||
}
|
||||
@@ -1254,6 +1783,21 @@ CppUnit::Test* DynamicAnyTest::suite()
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testLimitsInt);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testLimitsFloat);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testCtor);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testIsStruct);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testIsArray);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testArrayIdxOperator);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testDynamicStructBasics);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testDynamicStruct);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testArrayToString);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testStructToString);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testArrayOfStructsToString);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testStructWithArraysToString);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testJSONDeserializeString);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testJSONDeserializePrimitives);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testJSONDeserializeArray);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testJSONDeserializeStruct);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testJSONDeserializeComplex);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testDate);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DynamicAnyTest.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.h#4 $
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.h#5 $
|
||||
//
|
||||
// Tests for Any types
|
||||
//
|
||||
@@ -66,12 +66,40 @@ public:
|
||||
void testLimitsInt();
|
||||
void testLimitsFloat();
|
||||
void testCtor();
|
||||
void testIsStruct();
|
||||
void testIsArray();
|
||||
void testArrayIdxOperator();
|
||||
void testDynamicStructBasics();
|
||||
void testDynamicStruct();
|
||||
void testArrayToString();
|
||||
void testStructToString();
|
||||
void testArrayOfStructsToString();
|
||||
void testStructWithArraysToString();
|
||||
void testJSONDeserializeString();
|
||||
void testJSONDeserializePrimitives();
|
||||
void testJSONDeserializeArray();
|
||||
void testJSONDeserializeStruct();
|
||||
void testJSONDeserializeComplex();
|
||||
void testDate();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
void testGetIdxMustThrow(Poco::DynamicAny& a1, std::vector<Poco::DynamicAny>::size_type n);
|
||||
template<typename T>
|
||||
void testGetIdx(Poco::DynamicAny& a1, std::vector<Poco::DynamicAny>::size_type n, const T& expectedResult)
|
||||
{
|
||||
Poco::DynamicAny& val1 = a1[n];
|
||||
assert (val1 == expectedResult);
|
||||
|
||||
const Poco::DynamicAny& c1 = a1;
|
||||
const Poco::DynamicAny& cval1 = a1[n];
|
||||
assert (cval1 == expectedResult);
|
||||
}
|
||||
|
||||
|
||||
template<typename TL, typename TS>
|
||||
void testLimitsSigned()
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HTTPClientSession.h
|
||||
//
|
||||
// $Id: //poco/Main/Net/include/Poco/Net/HTTPClientSession.h#5 $
|
||||
// $Id: //poco/Main/Net/include/Poco/Net/HTTPClientSession.h#6 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: HTTPClient
|
||||
@@ -214,6 +214,9 @@ private:
|
||||
bool _expectResponseBody;
|
||||
std::ostream* _pRequestStream;
|
||||
std::istream* _pResponseStream;
|
||||
|
||||
HTTPClientSession(const HTTPClientSession&);
|
||||
HTTPClientSession& operator = (const HTTPClientSession&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HTTPRequest.h
|
||||
//
|
||||
// $Id: //poco/Main/Net/include/Poco/Net/HTTPRequest.h#2 $
|
||||
// $Id: //poco/Main/Net/include/Poco/Net/HTTPRequest.h#3 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: HTTP
|
||||
@@ -152,6 +152,9 @@ private:
|
||||
|
||||
std::string _method;
|
||||
std::string _uri;
|
||||
|
||||
HTTPRequest(const HTTPRequest&);
|
||||
HTTPRequest& operator = (const HTTPRequest&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HTTPResponse.h
|
||||
//
|
||||
// $Id: //poco/Main/Net/include/Poco/Net/HTTPResponse.h#2 $
|
||||
// $Id: //poco/Main/Net/include/Poco/Net/HTTPResponse.h#3 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: HTTP
|
||||
@@ -244,6 +244,9 @@ private:
|
||||
|
||||
HTTPStatus _status;
|
||||
std::string _reason;
|
||||
|
||||
HTTPResponse(const HTTPResponse&);
|
||||
HTTPResponse& operator = (const HTTPResponse&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// StringPartSource.h
|
||||
//
|
||||
// $Id: //poco/Main/Net/include/Poco/Net/StringPartSource.h#2 $
|
||||
// $Id: //poco/Main/Net/include/Poco/Net/StringPartSource.h#3 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: Messages
|
||||
@@ -78,6 +78,9 @@ public:
|
||||
private:
|
||||
std::istringstream _istr;
|
||||
std::string _filename;
|
||||
|
||||
StringPartSource(const StringPartSource&);
|
||||
StringPartSource& operator = (const StringPartSource&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HTTPClientSession.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Net/src/HTTPClientSession.cpp#18 $
|
||||
// $Id: //poco/Main/Net/src/HTTPClientSession.cpp#19 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: HTTPClient
|
||||
@@ -184,7 +184,8 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
|
||||
reconnect();
|
||||
if (!keepAlive)
|
||||
request.setKeepAlive(false);
|
||||
request.setHost(_host, _port);
|
||||
if (!request.has(HTTPRequest::HOST))
|
||||
request.setHost(_host, _port);
|
||||
if (!_proxyHost.empty())
|
||||
request.setURI(getHostInfo() + request.getURI());
|
||||
_reconnect = keepAlive;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HTTPServerRequestImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Net/src/HTTPServerRequestImpl.cpp#2 $
|
||||
// $Id: //poco/Main/Net/src/HTTPServerRequestImpl.cpp#3 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: HTTPServer
|
||||
@@ -54,9 +54,7 @@ namespace Net {
|
||||
HTTPServerRequestImpl::HTTPServerRequestImpl(HTTPServerResponse& response, HTTPServerSession& session, HTTPServerParams* pParams):
|
||||
_response(response),
|
||||
_pStream(0),
|
||||
_pParams(pParams),
|
||||
_clientAddress(session.clientAddress()),
|
||||
_serverAddress(session.serverAddress())
|
||||
_pParams(pParams)
|
||||
{
|
||||
poco_check_ptr (_pParams);
|
||||
|
||||
@@ -65,6 +63,10 @@ HTTPServerRequestImpl::HTTPServerRequestImpl(HTTPServerResponse& response, HTTPS
|
||||
HTTPHeaderInputStream hs(session);
|
||||
read(hs);
|
||||
|
||||
// Now that we know socket is still connected, obtain addresses
|
||||
_clientAddress = session.clientAddress();
|
||||
_serverAddress = session.serverAddress();
|
||||
|
||||
if (getChunkedTransferEncoding())
|
||||
_pStream = new HTTPChunkedInputStream(session);
|
||||
else if (getContentLength() != HTTPMessage::UNKNOWN_CONTENT_LENGTH)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// NetworkInterface.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Net/src/NetworkInterface.cpp#20 $
|
||||
// $Id: //poco/Main/Net/src/NetworkInterface.cpp#21 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: Sockets
|
||||
@@ -394,7 +394,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
|
||||
#endif
|
||||
|
||||
// Add IPv4 loopback interface (not returned by GetAdaptersInfo)
|
||||
result.push_back(NetworkInterface("Loopback", IPAddress("127.0.0.1"), -1));
|
||||
result.push_back(NetworkInterface("Loopback", IPAddress("127.0.0.1"), IPAddress("255.0.0.0"), IPAddress(), -1));
|
||||
// On Windows 2000 we use GetAdaptersInfo.
|
||||
PIP_ADAPTER_INFO pAdapterInfo;
|
||||
PIP_ADAPTER_INFO pInfo = 0;
|
||||
@@ -420,10 +420,13 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
|
||||
while (pInfo)
|
||||
{
|
||||
IPAddress address(std::string(pInfo->IpAddressList.IpAddress.String));
|
||||
IPAddress subnetMask(std::string(pInfo->IpAddressList.IpMask.String));
|
||||
IPAddress broadcastAddress(address);
|
||||
broadcastAddress.mask(subnetMask, IPAddress("255.255.255.255"));
|
||||
result.push_back(NetworkInterface(std::string(pInfo->AdapterName), address, subnetMask, broadcastAddress));
|
||||
if (!address.isWildcard()) // only return interfaces that have an address assigned.
|
||||
{
|
||||
IPAddress subnetMask(std::string(pInfo->IpAddressList.IpMask.String));
|
||||
IPAddress broadcastAddress(address);
|
||||
broadcastAddress.mask(subnetMask, IPAddress("255.255.255.255"));
|
||||
result.push_back(NetworkInterface(std::string(pInfo->AdapterName), address, subnetMask, broadcastAddress));
|
||||
}
|
||||
pInfo = pInfo->Next;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HTTPSClientSession.h
|
||||
//
|
||||
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/HTTPSClientSession.h#7 $
|
||||
// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/HTTPSClientSession.h#8 $
|
||||
//
|
||||
// Library: NetSSL_OpenSSL
|
||||
// Package: HTTPSClient
|
||||
@@ -99,6 +99,10 @@ protected:
|
||||
|
||||
std::string getHostInfo() const;
|
||||
/// Returns the target host and port number for proxy requests.
|
||||
|
||||
private:
|
||||
HTTPSClientSession(const HTTPSClientSession&);
|
||||
HTTPSClientSession& operator = (const HTTPSClientSession&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SecureSocketImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#21 $
|
||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#23 $
|
||||
//
|
||||
// Library: NetSSL_OpenSSL
|
||||
// Package: SSLSockets
|
||||
@@ -240,10 +240,6 @@ void SecureSocketImpl::connectNB(const SocketAddress& address)
|
||||
}
|
||||
else
|
||||
{
|
||||
int tmpSocket=0;
|
||||
BIO_get_fd(_pBIO,&tmpSocket);
|
||||
poco_assert (-1 != tmpSocket);
|
||||
setSockfd(tmpSocket);
|
||||
establishTunnel();
|
||||
connectSSL(address);
|
||||
poco_check_ptr (_pSSL);
|
||||
@@ -317,6 +313,7 @@ int SecureSocketImpl::receiveBytes(void* buffer, int length, int flags)
|
||||
poco_check_ptr (_pSSL);
|
||||
|
||||
int rc;
|
||||
bool renegotiating = false;
|
||||
do
|
||||
{
|
||||
rc = SSL_read(_pSSL, buffer, length);
|
||||
@@ -331,6 +328,8 @@ int SecureSocketImpl::receiveBytes(void* buffer, int length, int flags)
|
||||
case SSL_ERROR_NONE:
|
||||
case SSL_ERROR_WANT_WRITE: //renegotiation
|
||||
case SSL_ERROR_WANT_READ: //renegotiation
|
||||
renegotiating = true;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
@@ -339,7 +338,7 @@ int SecureSocketImpl::receiveBytes(void* buffer, int length, int flags)
|
||||
while (rc < 0 && _socket.lastError() == POCO_EINTR);
|
||||
if (rc < 0)
|
||||
{
|
||||
if (_socket.lastError() == POCO_EAGAIN || _socket.lastError() == POCO_ETIMEDOUT)
|
||||
if (renegotiating || _socket.lastError() == POCO_EAGAIN || _socket.lastError() == POCO_ETIMEDOUT)
|
||||
throw TimeoutException();
|
||||
else
|
||||
SocketImpl::error("failed to read bytes");
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Application.h
|
||||
//
|
||||
// $Id: //poco/Main/Util/include/Poco/Util/Application.h#14 $
|
||||
// $Id: //poco/Main/Util/include/Poco/Util/Application.h#15 $
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Application
|
||||
@@ -371,6 +371,9 @@ private:
|
||||
static Application* _pInstance;
|
||||
|
||||
friend class LoggingSubsystem;
|
||||
|
||||
Application(const Application&);
|
||||
Application& operator = (const Application&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Subsystem.h
|
||||
//
|
||||
// $Id: //poco/Main/Util/include/Poco/Util/Subsystem.h#3 $
|
||||
// $Id: //poco/Main/Util/include/Poco/Util/Subsystem.h#4 $
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Application
|
||||
@@ -107,6 +107,10 @@ protected:
|
||||
/// Destroys the Subsystem.
|
||||
|
||||
friend class Application;
|
||||
|
||||
private:
|
||||
Subsystem(const Subsystem&);
|
||||
Subsystem& operator = (const Subsystem&);
|
||||
};
|
||||
|
||||
|
||||
|
@@ -983,7 +983,8 @@ enum XML_FeatureEnum {
|
||||
XML_FEATURE_MIN_SIZE,
|
||||
XML_FEATURE_SIZEOF_XML_CHAR,
|
||||
XML_FEATURE_SIZEOF_XML_LCHAR,
|
||||
XML_FEATURE_NS
|
||||
XML_FEATURE_NS,
|
||||
XML_FEATURE_LARGE_SIZE
|
||||
/* Additional features must be added to the end of this enum. */
|
||||
};
|
||||
|
||||
@@ -1004,7 +1005,7 @@ XML_GetFeatureList(void);
|
||||
*/
|
||||
#define XML_MAJOR_VERSION 2
|
||||
#define XML_MINOR_VERSION 0
|
||||
#define XML_MICRO_VERSION 0
|
||||
#define XML_MICRO_VERSION 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -34,9 +34,9 @@
|
||||
system headers may assume the cdecl convention.
|
||||
*/
|
||||
#ifndef XMLCALL
|
||||
#if defined(XML_USE_MSC_EXTENSIONS)
|
||||
#if defined(_MSC_VER)
|
||||
#define XMLCALL __cdecl
|
||||
#elif defined(__GNUC__) && defined(__i386)
|
||||
#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
|
||||
#define XMLCALL __attribute__((cdecl))
|
||||
#else
|
||||
/* For any platform which uses this definition and supports more than
|
||||
@@ -65,6 +65,7 @@
|
||||
#endif
|
||||
#endif /* not defined XML_STATIC */
|
||||
|
||||
|
||||
/* If we didn't define it above, define it away: */
|
||||
#ifndef XMLIMPORT
|
||||
#define XMLIMPORT
|
||||
|
@@ -83,3 +83,10 @@
|
||||
#define ASCII_LSQB 0x5B
|
||||
#define ASCII_RSQB 0x5D
|
||||
#define ASCII_UNDERSCORE 0x5F
|
||||
#define ASCII_LPAREN 0x28
|
||||
#define ASCII_RPAREN 0x29
|
||||
#define ASCII_FF 0x0C
|
||||
#define ASCII_SLASH 0x2F
|
||||
#define ASCII_HASH 0x23
|
||||
#define ASCII_PIPE 0x7C
|
||||
#define ASCII_COMMA 0x2C
|
||||
|
@@ -20,7 +20,7 @@
|
||||
and therefore subject to change.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__)
|
||||
/* We'll use this version by default only where we know it helps.
|
||||
|
||||
regparm() generates warnings on Solaris boxes. See SF bug #692878.
|
||||
|
@@ -14,10 +14,13 @@
|
||||
#include "macconfig.h"
|
||||
#elif defined(__amigaos4__)
|
||||
#include "amigaconfig.h"
|
||||
#elif defined(__WATCOMC__)
|
||||
#include "watcomconfig.h"
|
||||
#elif defined(HAVE_EXPAT_CONFIG_H)
|
||||
#include "expat_config.h"
|
||||
#endif /* ndef COMPILED_FROM_DSP */
|
||||
|
||||
#include "ascii.h"
|
||||
#include "Poco/XML/expat.h"
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
@@ -26,7 +29,8 @@
|
||||
#define XmlGetInternalEncoding XmlGetUtf16InternalEncoding
|
||||
#define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS
|
||||
#define XmlEncode XmlUtf16Encode
|
||||
#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1))
|
||||
/* Using pointer subtraction to convert to integer type. */
|
||||
#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1))
|
||||
typedef unsigned short ICHAR;
|
||||
#else
|
||||
#define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX
|
||||
@@ -665,10 +669,12 @@ XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep)
|
||||
}
|
||||
|
||||
static const XML_Char implicitContext[] = {
|
||||
'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/',
|
||||
'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/',
|
||||
'X', 'M', 'L', '/', '1', '9', '9', '8', '/',
|
||||
'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0'
|
||||
ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, ASCII_t, ASCII_t, ASCII_p,
|
||||
ASCII_COLON, ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w,
|
||||
ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g,
|
||||
ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9,
|
||||
ASCII_9, ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e,
|
||||
ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, '\0'
|
||||
};
|
||||
|
||||
XML_Parser XMLCALL
|
||||
@@ -761,7 +767,7 @@ parserCreate(const XML_Char *encodingName,
|
||||
unknownEncodingHandler = NULL;
|
||||
unknownEncodingHandlerData = NULL;
|
||||
|
||||
namespaceSeparator = '!';
|
||||
namespaceSeparator = ASCII_EXCL;
|
||||
ns = XML_FALSE;
|
||||
ns_triplets = XML_FALSE;
|
||||
|
||||
@@ -1947,6 +1953,9 @@ XML_GetFeatureList(void)
|
||||
#endif
|
||||
#ifdef XML_NS
|
||||
{XML_FEATURE_NS, XML_L("XML_NS"), 0},
|
||||
#endif
|
||||
#ifdef XML_LARGE_SIZE
|
||||
{XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0},
|
||||
#endif
|
||||
{XML_FEATURE_END, NULL, 0}
|
||||
};
|
||||
@@ -2542,26 +2551,29 @@ doContent(XML_Parser parser,
|
||||
*nextPtr = end;
|
||||
return XML_ERROR_NONE;
|
||||
case XML_TOK_DATA_CHARS:
|
||||
if (characterDataHandler) {
|
||||
if (MUST_CONVERT(enc, s)) {
|
||||
for (;;) {
|
||||
ICHAR *dataPtr = (ICHAR *)dataBuf;
|
||||
XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
|
||||
*eventEndPP = s;
|
||||
characterDataHandler(handlerArg, dataBuf,
|
||||
(int)(dataPtr - (ICHAR *)dataBuf));
|
||||
if (s == next)
|
||||
break;
|
||||
*eventPP = s;
|
||||
{
|
||||
XML_CharacterDataHandler charDataHandler = characterDataHandler;
|
||||
if (charDataHandler) {
|
||||
if (MUST_CONVERT(enc, s)) {
|
||||
for (;;) {
|
||||
ICHAR *dataPtr = (ICHAR *)dataBuf;
|
||||
XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
|
||||
*eventEndPP = s;
|
||||
charDataHandler(handlerArg, dataBuf,
|
||||
(int)(dataPtr - (ICHAR *)dataBuf));
|
||||
if (s == next)
|
||||
break;
|
||||
*eventPP = s;
|
||||
}
|
||||
}
|
||||
else
|
||||
charDataHandler(handlerArg,
|
||||
(XML_Char *)s,
|
||||
(int)((XML_Char *)next - (XML_Char *)s));
|
||||
}
|
||||
else
|
||||
characterDataHandler(handlerArg,
|
||||
(XML_Char *)s,
|
||||
(int)((XML_Char *)next - (XML_Char *)s));
|
||||
else if (defaultHandler)
|
||||
reportDefault(parser, enc, s, next);
|
||||
}
|
||||
else if (defaultHandler)
|
||||
reportDefault(parser, enc, s, next);
|
||||
break;
|
||||
case XML_TOK_PI:
|
||||
if (!reportProcessingInstruction(parser, enc, s, next))
|
||||
@@ -2806,7 +2818,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
uriHash = CHAR_HASH(uriHash, c);
|
||||
}
|
||||
while (*s++ != XML_T(':'))
|
||||
while (*s++ != XML_T(ASCII_COLON))
|
||||
;
|
||||
do { /* copies null terminator */
|
||||
const XML_Char c = *s;
|
||||
@@ -2880,7 +2892,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
|
||||
if (!binding)
|
||||
return XML_ERROR_UNBOUND_PREFIX;
|
||||
localPart = tagNamePtr->str;
|
||||
while (*localPart++ != XML_T(':'))
|
||||
while (*localPart++ != XML_T(ASCII_COLON))
|
||||
;
|
||||
}
|
||||
else if (dtd->defaultPrefix.binding) {
|
||||
@@ -2935,17 +2947,21 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
|
||||
const XML_Char *uri, BINDING **bindingsPtr)
|
||||
{
|
||||
static const XML_Char xmlNamespace[] = {
|
||||
'h', 't', 't', 'p', ':', '/', '/',
|
||||
'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/',
|
||||
'X', 'M', 'L', '/', '1', '9', '9', '8', '/',
|
||||
'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0'
|
||||
ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH,
|
||||
ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD,
|
||||
ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L,
|
||||
ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, ASCII_SLASH,
|
||||
ASCII_n, ASCII_a, ASCII_m, ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c,
|
||||
ASCII_e, '\0'
|
||||
};
|
||||
static const int xmlLen =
|
||||
(int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1;
|
||||
static const XML_Char xmlnsNamespace[] = {
|
||||
'h', 't', 't', 'p', ':', '/', '/',
|
||||
'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/',
|
||||
'2', '0', '0', '0', '/', 'x', 'm', 'l', 'n', 's', '/', '\0'
|
||||
ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH,
|
||||
ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD,
|
||||
ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0,
|
||||
ASCII_0, ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s,
|
||||
ASCII_SLASH, '\0'
|
||||
};
|
||||
static const int xmlnsLen =
|
||||
(int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1;
|
||||
@@ -2962,13 +2978,13 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
|
||||
return XML_ERROR_UNDECLARING_PREFIX;
|
||||
|
||||
if (prefix->name
|
||||
&& prefix->name[0] == XML_T('x')
|
||||
&& prefix->name[1] == XML_T('m')
|
||||
&& prefix->name[2] == XML_T('l')) {
|
||||
&& prefix->name[0] == XML_T(ASCII_x)
|
||||
&& prefix->name[1] == XML_T(ASCII_m)
|
||||
&& prefix->name[2] == XML_T(ASCII_l)) {
|
||||
|
||||
/* Not allowed to bind xmlns */
|
||||
if (prefix->name[3] == XML_T('n')
|
||||
&& prefix->name[4] == XML_T('s')
|
||||
if (prefix->name[3] == XML_T(ASCII_n)
|
||||
&& prefix->name[4] == XML_T(ASCII_s)
|
||||
&& prefix->name[5] == XML_T('\0'))
|
||||
return XML_ERROR_RESERVED_PREFIX_XMLNS;
|
||||
|
||||
@@ -3122,26 +3138,29 @@ doCdataSection(XML_Parser parser,
|
||||
reportDefault(parser, enc, s, next);
|
||||
break;
|
||||
case XML_TOK_DATA_CHARS:
|
||||
if (characterDataHandler) {
|
||||
if (MUST_CONVERT(enc, s)) {
|
||||
for (;;) {
|
||||
ICHAR *dataPtr = (ICHAR *)dataBuf;
|
||||
XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
|
||||
*eventEndPP = next;
|
||||
characterDataHandler(handlerArg, dataBuf,
|
||||
(int)(dataPtr - (ICHAR *)dataBuf));
|
||||
if (s == next)
|
||||
break;
|
||||
*eventPP = s;
|
||||
{
|
||||
XML_CharacterDataHandler charDataHandler = characterDataHandler;
|
||||
if (charDataHandler) {
|
||||
if (MUST_CONVERT(enc, s)) {
|
||||
for (;;) {
|
||||
ICHAR *dataPtr = (ICHAR *)dataBuf;
|
||||
XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
|
||||
*eventEndPP = next;
|
||||
charDataHandler(handlerArg, dataBuf,
|
||||
(int)(dataPtr - (ICHAR *)dataBuf));
|
||||
if (s == next)
|
||||
break;
|
||||
*eventPP = s;
|
||||
}
|
||||
}
|
||||
else
|
||||
charDataHandler(handlerArg,
|
||||
(XML_Char *)s,
|
||||
(int)((XML_Char *)next - (XML_Char *)s));
|
||||
}
|
||||
else
|
||||
characterDataHandler(handlerArg,
|
||||
(XML_Char *)s,
|
||||
(int)((XML_Char *)next - (XML_Char *)s));
|
||||
else if (defaultHandler)
|
||||
reportDefault(parser, enc, s, next);
|
||||
}
|
||||
else if (defaultHandler)
|
||||
reportDefault(parser, enc, s, next);
|
||||
break;
|
||||
case XML_TOK_INVALID:
|
||||
*eventPP = next;
|
||||
@@ -3628,23 +3647,27 @@ doProlog(XML_Parser parser,
|
||||
XML_Bool haveMore)
|
||||
{
|
||||
#ifdef XML_DTD
|
||||
static const XML_Char externalSubsetName[] = { '#' , '\0' };
|
||||
static const XML_Char externalSubsetName[] = { ASCII_HASH , '\0' };
|
||||
#endif /* XML_DTD */
|
||||
static const XML_Char atypeCDATA[] = { 'C', 'D', 'A', 'T', 'A', '\0' };
|
||||
static const XML_Char atypeID[] = { 'I', 'D', '\0' };
|
||||
static const XML_Char atypeIDREF[] = { 'I', 'D', 'R', 'E', 'F', '\0' };
|
||||
static const XML_Char atypeIDREFS[] = { 'I', 'D', 'R', 'E', 'F', 'S', '\0' };
|
||||
static const XML_Char atypeENTITY[] = { 'E', 'N', 'T', 'I', 'T', 'Y', '\0' };
|
||||
static const XML_Char atypeENTITIES[] =
|
||||
{ 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S', '\0' };
|
||||
static const XML_Char atypeCDATA[] =
|
||||
{ ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
|
||||
static const XML_Char atypeID[] = { ASCII_I, ASCII_D, '\0' };
|
||||
static const XML_Char atypeIDREF[] =
|
||||
{ ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
|
||||
static const XML_Char atypeIDREFS[] =
|
||||
{ ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
|
||||
static const XML_Char atypeENTITY[] =
|
||||
{ ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' };
|
||||
static const XML_Char atypeENTITIES[] = { ASCII_E, ASCII_N,
|
||||
ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' };
|
||||
static const XML_Char atypeNMTOKEN[] = {
|
||||
'N', 'M', 'T', 'O', 'K', 'E', 'N', '\0' };
|
||||
static const XML_Char atypeNMTOKENS[] = {
|
||||
'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S', '\0' };
|
||||
static const XML_Char notationPrefix[] = {
|
||||
'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(', '\0' };
|
||||
static const XML_Char enumValueSep[] = { '|', '\0' };
|
||||
static const XML_Char enumValueStart[] = { '(', '\0' };
|
||||
ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' };
|
||||
static const XML_Char atypeNMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T,
|
||||
ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' };
|
||||
static const XML_Char notationPrefix[] = { ASCII_N, ASCII_O, ASCII_T,
|
||||
ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0' };
|
||||
static const XML_Char enumValueSep[] = { ASCII_PIPE, '\0' };
|
||||
static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' };
|
||||
|
||||
/* save one level of indirection */
|
||||
DTD * const dtd = _dtd;
|
||||
@@ -3950,11 +3973,11 @@ doProlog(XML_Parser parser,
|
||||
0, parser))
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
if (attlistDeclHandler && declAttributeType) {
|
||||
if (*declAttributeType == XML_T('(')
|
||||
|| (*declAttributeType == XML_T('N')
|
||||
&& declAttributeType[1] == XML_T('O'))) {
|
||||
if (*declAttributeType == XML_T(ASCII_LPAREN)
|
||||
|| (*declAttributeType == XML_T(ASCII_N)
|
||||
&& declAttributeType[1] == XML_T(ASCII_O))) {
|
||||
/* Enumerated or Notation type */
|
||||
if (!poolAppendChar(&tempPool, XML_T(')'))
|
||||
if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN))
|
||||
|| !poolAppendChar(&tempPool, XML_T('\0')))
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
declAttributeType = tempPool.start;
|
||||
@@ -3987,11 +4010,11 @@ doProlog(XML_Parser parser,
|
||||
declAttributeIsCdata, XML_FALSE, attVal, parser))
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
if (attlistDeclHandler && declAttributeType) {
|
||||
if (*declAttributeType == XML_T('(')
|
||||
|| (*declAttributeType == XML_T('N')
|
||||
&& declAttributeType[1] == XML_T('O'))) {
|
||||
if (*declAttributeType == XML_T(ASCII_LPAREN)
|
||||
|| (*declAttributeType == XML_T(ASCII_N)
|
||||
&& declAttributeType[1] == XML_T(ASCII_O))) {
|
||||
/* Enumerated or Notation type */
|
||||
if (!poolAppendChar(&tempPool, XML_T(')'))
|
||||
if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN))
|
||||
|| !poolAppendChar(&tempPool, XML_T('\0')))
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
declAttributeType = tempPool.start;
|
||||
@@ -4318,14 +4341,14 @@ doProlog(XML_Parser parser,
|
||||
}
|
||||
break;
|
||||
case XML_ROLE_GROUP_SEQUENCE:
|
||||
if (groupConnector[prologState.level] == '|')
|
||||
if (groupConnector[prologState.level] == ASCII_PIPE)
|
||||
return XML_ERROR_SYNTAX;
|
||||
groupConnector[prologState.level] = ',';
|
||||
groupConnector[prologState.level] = ASCII_COMMA;
|
||||
if (dtd->in_eldecl && elementDeclHandler)
|
||||
handleDefault = XML_FALSE;
|
||||
break;
|
||||
case XML_ROLE_GROUP_CHOICE:
|
||||
if (groupConnector[prologState.level] == ',')
|
||||
if (groupConnector[prologState.level] == ASCII_COMMA)
|
||||
return XML_ERROR_SYNTAX;
|
||||
if (dtd->in_eldecl
|
||||
&& !groupConnector[prologState.level]
|
||||
@@ -4337,7 +4360,7 @@ doProlog(XML_Parser parser,
|
||||
if (elementDeclHandler)
|
||||
handleDefault = XML_FALSE;
|
||||
}
|
||||
groupConnector[prologState.level] = '|';
|
||||
groupConnector[prologState.level] = ASCII_PIPE;
|
||||
break;
|
||||
case XML_ROLE_PARAM_ENTITY_REF:
|
||||
#ifdef XML_DTD
|
||||
@@ -5267,7 +5290,7 @@ setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType)
|
||||
DTD * const dtd = _dtd; /* save one level of indirection */
|
||||
const XML_Char *name;
|
||||
for (name = elementType->name; *name; name++) {
|
||||
if (*name == XML_T(':')) {
|
||||
if (*name == XML_T(ASCII_COLON)) {
|
||||
PREFIX *prefix;
|
||||
const XML_Char *s;
|
||||
for (s = elementType->name; s != name; s++) {
|
||||
@@ -5314,12 +5337,12 @@ getAttributeId(XML_Parser parser, const ENCODING *enc,
|
||||
poolFinish(&dtd->pool);
|
||||
if (!ns)
|
||||
;
|
||||
else if (name[0] == XML_T('x')
|
||||
&& name[1] == XML_T('m')
|
||||
&& name[2] == XML_T('l')
|
||||
&& name[3] == XML_T('n')
|
||||
&& name[4] == XML_T('s')
|
||||
&& (name[5] == XML_T('\0') || name[5] == XML_T(':'))) {
|
||||
else if (name[0] == XML_T(ASCII_x)
|
||||
&& name[1] == XML_T(ASCII_m)
|
||||
&& name[2] == XML_T(ASCII_l)
|
||||
&& name[3] == XML_T(ASCII_n)
|
||||
&& name[4] == XML_T(ASCII_s)
|
||||
&& (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) {
|
||||
if (name[5] == XML_T('\0'))
|
||||
id->prefix = &dtd->defaultPrefix;
|
||||
else
|
||||
@@ -5330,7 +5353,7 @@ getAttributeId(XML_Parser parser, const ENCODING *enc,
|
||||
int i;
|
||||
for (i = 0; name[i]; i++) {
|
||||
/* attributes without prefix are *not* in the default namespace */
|
||||
if (name[i] == XML_T(':')) {
|
||||
if (name[i] == XML_T(ASCII_COLON)) {
|
||||
int j;
|
||||
for (j = 0; j < i; j++) {
|
||||
if (!poolAppendChar(&dtd->pool, name[j]))
|
||||
@@ -5352,7 +5375,7 @@ getAttributeId(XML_Parser parser, const ENCODING *enc,
|
||||
return id;
|
||||
}
|
||||
|
||||
#define CONTEXT_SEP XML_T('\f')
|
||||
#define CONTEXT_SEP XML_T(ASCII_FF)
|
||||
|
||||
static const XML_Char *
|
||||
getContext(XML_Parser parser)
|
||||
@@ -5364,7 +5387,7 @@ getContext(XML_Parser parser)
|
||||
if (dtd->defaultPrefix.binding) {
|
||||
int i;
|
||||
int len;
|
||||
if (!poolAppendChar(&tempPool, XML_T('=')))
|
||||
if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS)))
|
||||
return NULL;
|
||||
len = dtd->defaultPrefix.binding->uriLen;
|
||||
if (namespaceSeparator)
|
||||
@@ -5390,7 +5413,7 @@ getContext(XML_Parser parser)
|
||||
for (s = prefix->name; *s; s++)
|
||||
if (!poolAppendChar(&tempPool, *s))
|
||||
return NULL;
|
||||
if (!poolAppendChar(&tempPool, XML_T('=')))
|
||||
if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS)))
|
||||
return NULL;
|
||||
len = prefix->binding->uriLen;
|
||||
if (namespaceSeparator)
|
||||
@@ -5442,7 +5465,7 @@ setContext(XML_Parser parser, const XML_Char *context)
|
||||
context = s;
|
||||
poolDiscard(&tempPool);
|
||||
}
|
||||
else if (*s == XML_T('=')) {
|
||||
else if (*s == XML_T(ASCII_EQUALS)) {
|
||||
PREFIX *prefix;
|
||||
if (poolLength(&tempPool) == 0)
|
||||
prefix = &dtd->defaultPrefix;
|
||||
|
@@ -10,6 +10,8 @@
|
||||
#include "macconfig.h"
|
||||
#elif defined(__amigaos4__)
|
||||
#include "amigaconfig.h"
|
||||
#elif defined(__WATCOMC__)
|
||||
#include "watcomconfig.h"
|
||||
#else
|
||||
#ifdef HAVE_EXPAT_CONFIG_H
|
||||
#include "expat_config.h"
|
||||
@@ -53,12 +55,16 @@ static const char KW_IDREF[] = {
|
||||
ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
|
||||
static const char KW_IDREFS[] = {
|
||||
ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
|
||||
#ifdef XML_DTD
|
||||
static const char KW_IGNORE[] = {
|
||||
ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' };
|
||||
#endif
|
||||
static const char KW_IMPLIED[] = {
|
||||
ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' };
|
||||
#ifdef XML_DTD
|
||||
static const char KW_INCLUDE[] = {
|
||||
ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' };
|
||||
#endif
|
||||
static const char KW_NDATA[] = {
|
||||
ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
|
||||
static const char KW_NMTOKEN[] = {
|
||||
|
@@ -10,6 +10,8 @@
|
||||
#include "macconfig.h"
|
||||
#elif defined(__amigaos4__)
|
||||
#include "amigaconfig.h"
|
||||
#elif defined(__WATCOMC__)
|
||||
#include "watcomconfig.h"
|
||||
#else
|
||||
#ifdef HAVE_EXPAT_CONFIG_H
|
||||
#include "expat_config.h"
|
||||
@@ -295,7 +297,9 @@ sb_charMatches(const ENCODING *enc, const char *p, int c)
|
||||
#endif
|
||||
|
||||
#define PREFIX(ident) normal_ ## ident
|
||||
#define XML_TOK_IMPL_C
|
||||
#include "xmltok_impl.c"
|
||||
#undef XML_TOK_IMPL_C
|
||||
|
||||
#undef MINBPC
|
||||
#undef BYTE_TYPE
|
||||
@@ -692,7 +696,9 @@ little2_isNmstrtMin(const ENCODING *enc, const char *p)
|
||||
#define IS_NMSTRT_CHAR(enc, p, n) (0)
|
||||
#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
|
||||
|
||||
#define XML_TOK_IMPL_C
|
||||
#include "xmltok_impl.c"
|
||||
#undef XML_TOK_IMPL_C
|
||||
|
||||
#undef MINBPC
|
||||
#undef BYTE_TYPE
|
||||
@@ -831,7 +837,9 @@ big2_isNmstrtMin(const ENCODING *enc, const char *p)
|
||||
#define IS_NMSTRT_CHAR(enc, p, n) (0)
|
||||
#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
|
||||
|
||||
#define XML_TOK_IMPL_C
|
||||
#include "xmltok_impl.c"
|
||||
#undef XML_TOK_IMPL_C
|
||||
|
||||
#undef MINBPC
|
||||
#undef BYTE_TYPE
|
||||
@@ -1610,7 +1618,9 @@ initScan(const ENCODING * const *encodingTable,
|
||||
|
||||
#define NS(x) x
|
||||
#define ns(x) x
|
||||
#define XML_TOK_NS_C
|
||||
#include "xmltok_ns.c"
|
||||
#undef XML_TOK_NS_C
|
||||
#undef NS
|
||||
#undef ns
|
||||
|
||||
@@ -1619,7 +1629,9 @@ initScan(const ENCODING * const *encodingTable,
|
||||
#define NS(x) x ## NS
|
||||
#define ns(x) x ## _ns
|
||||
|
||||
#define XML_TOK_NS_C
|
||||
#include "xmltok_ns.c"
|
||||
#undef XML_TOK_NS_C
|
||||
|
||||
#undef NS
|
||||
#undef ns
|
||||
|
@@ -2,6 +2,9 @@
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* This file is included! */
|
||||
#ifdef XML_TOK_IMPL_C
|
||||
|
||||
#ifndef IS_INVALID_CHAR
|
||||
#define IS_INVALID_CHAR(enc, ptr, n) (0)
|
||||
#endif
|
||||
@@ -1777,3 +1780,4 @@ PREFIX(updatePosition)(const ENCODING *enc,
|
||||
#undef CHECK_NMSTRT_CASE
|
||||
#undef CHECK_NMSTRT_CASES
|
||||
|
||||
#endif /* XML_TOK_IMPL_C */
|
||||
|
@@ -1,3 +1,10 @@
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* This file is included! */
|
||||
#ifdef XML_TOK_NS_C
|
||||
|
||||
const ENCODING *
|
||||
NS(XmlGetUtf8InternalEncoding)(void)
|
||||
{
|
||||
@@ -104,3 +111,5 @@ NS(XmlParseXmlDecl)(int isGeneralTextEntity,
|
||||
encoding,
|
||||
standalone);
|
||||
}
|
||||
|
||||
#endif /* XML_TOK_NS_C */
|
||||
|
Reference in New Issue
Block a user