git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30791
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
protected:
wxArchiveEntry() : m_notifier(NULL) { }
protected:
wxArchiveEntry() : m_notifier(NULL) { }
+ wxArchiveEntry(const wxArchiveEntry& e) : wxObject(e), m_notifier(NULL) { }
virtual void SetOffset(wxFileOffset offset) = 0;
virtual wxArchiveEntry* DoClone() const = 0;
virtual void SetOffset(wxFileOffset offset) = 0;
virtual wxArchiveEntry* DoClone() const = 0;
#include <iterator>
#include <utility>
#include <iterator>
#include <utility>
-template <class X, class Y>
-void WXDLLIMPEXP_BASE _wxSetArchiveIteratorValue(
+template <class X, class Y> inline
+void _wxSetArchiveIteratorValue(
X& val, Y entry, void *WXUNUSED(d))
{
val = X(entry);
}
X& val, Y entry, void *WXUNUSED(d))
{
val = X(entry);
}
-template <class X, class Y, class Z>
-void WXDLLIMPEXP_BASE _wxSetArchiveIteratorValue(
+template <class X, class Y, class Z> inline
+void _wxSetArchiveIteratorValue(
std::pair<X, Y>& val, Z entry, Z WXUNUSED(d))
{
val = std::make_pair(X(entry->GetInternalName()), Y(entry));
std::pair<X, Y>& val, Z entry, Z WXUNUSED(d))
{
val = std::make_pair(X(entry->GetInternalName()), Y(entry));
#else
template <class Arc, class T = typename Arc::entry_type*>
#endif
#else
template <class Arc, class T = typename Arc::entry_type*>
#endif
-class WXDLLIMPEXP_BASE wxArchiveIterator
{
public:
typedef std::input_iterator_tag iterator_category;
{
public:
typedef std::input_iterator_tag iterator_category;
- bool operator ==(const wxArchiveIterator& j) {
- return (*this).m_rep == j.m_rep;
+ bool operator ==(const wxArchiveIterator& j) const {
+ return m_rep == j.m_rep;
- bool operator !=(const wxArchiveIterator& j) {
+ bool operator !=(const wxArchiveIterator& j) const {
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
typedef wxArchiveIterator<wxZipInputStream> wxZipIter;
typedef wxArchiveIterator<wxZipInputStream,
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
typedef wxArchiveIterator<wxZipInputStream> wxZipIter;
typedef wxArchiveIterator<wxZipInputStream,
- std::pair<wxString, wxZipEntry*> > wxZipPairIter;
+ std::pair<wxString, wxZipEntry*> > wxZipPairIter;
#endif
/////////////////////////////////////////////////////////////////////////////
// wxZipEntry inlines
#endif
/////////////////////////////////////////////////////////////////////////////
// wxZipEntry inlines
-bool wxZipEntry::IsText() const
+inline bool wxZipEntry::IsText() const
{
return (m_InternalAttributes & TEXT_ATTR) != 0;
}
{
return (m_InternalAttributes & TEXT_ATTR) != 0;
}
-bool wxZipEntry::IsDir() const
+inline bool wxZipEntry::IsDir() const
{
return (m_ExternalAttributes & wxZIP_A_SUBDIR) != 0;
}
{
return (m_ExternalAttributes & wxZIP_A_SUBDIR) != 0;
}
-bool wxZipEntry::IsReadOnly() const
+inline bool wxZipEntry::IsReadOnly() const
{
return (m_ExternalAttributes & wxZIP_A_RDONLY) != 0;
}
{
return (m_ExternalAttributes & wxZIP_A_RDONLY) != 0;
}
-bool wxZipEntry::IsMadeByUnix() const
+inline bool wxZipEntry::IsMadeByUnix() const
{
const int pattern =
(1 << wxZIP_SYSTEM_OPENVMS) |
{
const int pattern =
(1 << wxZIP_SYSTEM_OPENVMS) |
|| ((pattern >> m_SystemMadeBy) & 1);
}
|| ((pattern >> m_SystemMadeBy) & 1);
}
-void wxZipEntry::SetIsText(bool isText)
+inline void wxZipEntry::SetIsText(bool isText)
{
if (isText)
m_InternalAttributes |= TEXT_ATTR;
{
if (isText)
m_InternalAttributes |= TEXT_ATTR;
m_InternalAttributes &= ~TEXT_ATTR;
}
m_InternalAttributes &= ~TEXT_ATTR;
}
-void wxZipEntry::SetIsReadOnly(bool isReadOnly)
+inline void wxZipEntry::SetIsReadOnly(bool isReadOnly)
{
if (isReadOnly)
SetMode(GetMode() & ~0222);
{
if (isReadOnly)
SetMode(GetMode() & ~0222);
SetMode(GetMode() | 0200);
}
SetMode(GetMode() | 0200);
}
-void wxZipEntry::SetName(const wxString& name,
- wxPathFormat format /*=wxPATH_NATIVE*/)
+inline void wxZipEntry::SetName(const wxString& name,
+ wxPathFormat format /*=wxPATH_NATIVE*/)
{
bool isDir;
m_Name = GetInternalName(name, format, &isDir);
{
bool isDir;
m_Name = GetInternalName(name, format, &isDir);
m_notifier->OnEntryUpdated(*this);
}
m_notifier->OnEntryUpdated(*this);
}
-wxArchiveEntry& wxArchiveEntry::operator=(const wxArchiveEntry& entry)
+wxArchiveEntry& wxArchiveEntry::operator=(const wxArchiveEntry& WXUNUSED(e))
- m_notifier = entry.m_notifier;
}
wxZipEntry::wxZipEntry(const wxZipEntry& e)
}
wxZipEntry::wxZipEntry(const wxZipEntry& e)
- : m_SystemMadeBy(e.m_SystemMadeBy),
+ : wxArchiveEntry(e),
+ m_SystemMadeBy(e.m_SystemMadeBy),
m_VersionMadeBy(e.m_VersionMadeBy),
m_VersionNeeded(e.m_VersionNeeded),
m_Flags(e.m_Flags),
m_VersionMadeBy(e.m_VersionMadeBy),
m_VersionNeeded(e.m_VersionNeeded),
m_Flags(e.m_Flags),
m_ExternalAttributes(e.m_ExternalAttributes),
m_Extra(AddRef(e.m_Extra)),
m_LocalExtra(AddRef(e.m_LocalExtra)),
m_ExternalAttributes(e.m_ExternalAttributes),
m_Extra(AddRef(e.m_Extra)),
m_LocalExtra(AddRef(e.m_LocalExtra)),
- m_zipnotifier(e.m_zipnotifier),
m_ExternalAttributes = e.m_ExternalAttributes;
Copy(m_Extra, e.m_Extra);
Copy(m_LocalExtra, e.m_LocalExtra);
m_ExternalAttributes = e.m_ExternalAttributes;
Copy(m_Extra, e.m_Extra);
Copy(m_LocalExtra, e.m_LocalExtra);
- m_zipnotifier = e.m_zipnotifier;
if (m_backlink) {
m_backlink->Release(m_Key);
m_backlink = NULL;
if (m_backlink) {
m_backlink->Release(m_Key);
m_backlink = NULL;
#define WX_TEST_ARCHIVE_ITERATOR
#define WX_TEST_ARCHIVE_ITERATOR
-// This sample uses some advanced typedef syntax that messes
-// up MSVC 6 - turn off its warning about it
-#if defined _MSC_VER
+// VC++ 6 warns that the list iterator's '->' operator will not work whenever
+// std::list is used with a non-pointer, so switch it off.
+#if defined _MSC_VER && _MSC_VER < 1300
#pragma warning (disable:4284)
#endif
#pragma warning (disable:4284)
#endif
{
public:
TestEntry(const wxDateTime& dt, int len, const char *data);
{
public:
TestEntry(const wxDateTime& dt, int len, const char *data);
- ~TestEntry() { delete [] (char*) m_data; }
+ ~TestEntry() { delete [] m_data; }
wxDateTime GetDateTime() const { return m_dt; }
wxFileOffset GetLength() const { return m_len; }
wxDateTime GetDateTime() const { return m_dt; }
wxFileOffset GetLength() const { return m_len; }
private:
wxDateTime m_dt;
size_t m_len;
private:
wxDateTime m_dt;
size_t m_len;
wxString m_comment;
bool m_isText;
};
wxString m_comment;
bool m_isText;
};
m_len(len),
m_isText(len > 0)
{
m_len(len),
m_isText(len > 0)
{
- char *d = new char[len];
- memcpy(d, data, len);
- m_data = d;
+ m_data = new char[len];
+ memcpy(m_data, data, len);
for (int i = 0; i < len && m_isText; i++)
m_isText = (signed char)m_data[i] > 0;
for (int i = 0; i < len && m_isText; i++)
m_isText = (signed char)m_data[i] > 0;
wxFileOffset GetLength() const { return m_size; }
// gives away the data, this stream is then empty, and can be reused
wxFileOffset GetLength() const { return m_size; }
// gives away the data, this stream is then empty, and can be reused
- void GetData(const char*& data, size_t& size);
+ void GetData(char*& data, size_t& size);
enum { STUB_SIZE = 2048, INITIAL_SIZE = 0x18000, SEEK_LIMIT = 0x100000 };
enum { STUB_SIZE = 2048, INITIAL_SIZE = 0x18000, SEEK_LIMIT = 0x100000 };
-void TestOutputStream::GetData(const char*& data, size_t& size)
+void TestOutputStream::GetData(char*& data, size_t& size)
{
data = m_data;
size = m_size;
{
data = m_data;
size = m_size;
TestInputStream(TestOutputStream& out) : m_data(NULL) { SetData(out); }
// this ctor 'dups'
TestInputStream(const TestInputStream& in);
TestInputStream(TestOutputStream& out) : m_data(NULL) { SetData(out); }
// this ctor 'dups'
TestInputStream(const TestInputStream& in);
- ~TestInputStream() { delete [] (char*) m_data; }
+ ~TestInputStream() { delete [] m_data; }
void Rewind();
wxFileOffset GetLength() const { return m_size; }
void Rewind();
wxFileOffset GetLength() const { return m_size; }
int m_options;
size_t m_pos;
size_t m_size;
int m_options;
size_t m_pos;
size_t m_size;
};
TestInputStream::TestInputStream(const TestInputStream& in)
};
TestInputStream::TestInputStream(const TestInputStream& in)
m_pos(in.m_pos),
m_size(in.m_size)
{
m_pos(in.m_pos),
m_size(in.m_size)
{
- char *p = new char[m_size];
- memcpy(p, in.m_data, m_size);
- m_data = p;
+ m_data = new char[m_size];
+ memcpy(m_data, in.m_data, m_size);
}
void TestInputStream::Rewind()
}
void TestInputStream::Rewind()
void TestInputStream::SetData(TestOutputStream& out)
{
void TestInputStream::SetData(TestOutputStream& out)
{
- delete [] (char*) m_data;
m_options = out.GetOptions();
out.GetData(m_data, m_size);
Rewind();
m_options = out.GetOptions();
out.GetData(m_data, m_size);
Rewind();
{
wxCharBuffer buf(len);
for (int i = 0; i < len; i++)
{
wxCharBuffer buf(len);
for (int i = 0; i < len; i++)
- buf.data()[i] = value == EOF ? rand() : value;
+ buf.data()[i] = (char)(value == EOF ? rand() : value);
return Add(name, buf, len);
}
return Add(name, buf, len);
}
{
auto_ptr<InputStreamT> arcIn(m_factory->NewStream(in));
auto_ptr<OutputStreamT> arcOut(m_factory->NewStream(out));
{
auto_ptr<InputStreamT> arcIn(m_factory->NewStream(in));
auto_ptr<OutputStreamT> arcOut(m_factory->NewStream(out));
const wxString deleteName = _T("bin/bin1000");
const wxString renameFrom = _T("zero/zero1024");
const wxString deleteName = _T("bin/bin1000");
const wxString renameFrom = _T("zero/zero1024");
arcOut->CopyArchiveMetaData(*arcIn);
arcOut->CopyArchiveMetaData(*arcIn);
- auto_ptr<EntryT>* pEntry;
-
- for (pEntry = new auto_ptr<EntryT>(arcIn->GetNextEntry()) ;
- pEntry->get() != NULL ;
- delete pEntry, pEntry = new auto_ptr<EntryT>(arcIn->GetNextEntry()))
- {
- OnSetNotifier(**pEntry);
- wxString name = (*pEntry)->GetName(wxPATH_UNIX);
+ while ((pEntry = arcIn->GetNextEntry()) != NULL) {
+ auto_ptr<EntryT> entry(pEntry);
+ OnSetNotifier(*entry);
+ wxString name = entry->GetName(wxPATH_UNIX);
// provide some context for the error message so that we know which
// iteration of the loop we were on
// provide some context for the error message so that we know which
// iteration of the loop we were on
}
else {
if (name == renameFrom) {
}
else {
if (name == renameFrom) {
- (*pEntry)->SetName(renameTo);
+ entry->SetName(renameTo);
TestEntries::iterator it = m_testEntries.find(renameFrom);
CPPUNIT_ASSERT_MESSAGE(
"rename failed (already renamed?) for" + error_entry,
TestEntries::iterator it = m_testEntries.find(renameFrom);
CPPUNIT_ASSERT_MESSAGE(
"rename failed (already renamed?) for" + error_entry,
}
CPPUNIT_ASSERT_MESSAGE("CopyEntry" + error_context,
}
CPPUNIT_ASSERT_MESSAGE("CopyEntry" + error_context,
- arcOut->CopyEntry(pEntry->release(), *arcIn));
+ arcOut->CopyEntry(entry.release(), *arcIn));
// check that the deletion and rename were done
CPPUNIT_ASSERT(m_testEntries.count(deleteName) == 0);
CPPUNIT_ASSERT(m_testEntries.count(renameFrom) == 0);
// check that the deletion and rename were done
CPPUNIT_ASSERT(m_testEntries.count(deleteName) == 0);
CPPUNIT_ASSERT(m_testEntries.count(renameFrom) == 0);
CPPUNIT_ASSERT_MESSAGE(
"entry not found in archive" + error_entry, in.Ok());
CPPUNIT_ASSERT_MESSAGE(
"entry not found in archive" + error_entry, in.Ok());
- size_t size = in.GetLength();
+ size_t size = (size_t)in.GetLength();
wxCharBuffer buf(size);
CPPUNIT_ASSERT_MESSAGE("Read" + error_context,
in.Read(buf.data(), size).LastRead() == size);
wxCharBuffer buf(size);
CPPUNIT_ASSERT_MESSAGE("Read" + error_context,
in.Read(buf.data(), size).LastRead() == size);
template <class Classes>
void ArchiveTestCase<Classes>::TestSmartPairIterator(wxInputStream& in)
{
template <class Classes>
void ArchiveTestCase<Classes>::TestSmartPairIterator(wxInputStream& in)
{
+#if defined _MSC_VER && defined _MSC_VER < 1200
+ // With VC++ 5.0 the '=' operator of std::pair breaks when the second
+ // type is Ptr<EntryT>, so this iterator can't be made to work.
+ (void)in;
+#else
typedef std::map<wxString, Ptr<EntryT> > ArchiveCatalog;
typedef typename ArchiveCatalog::iterator CatalogIter;
typedef wxArchiveIterator<InputStreamT,
typedef std::map<wxString, Ptr<EntryT> > ArchiveCatalog;
typedef typename ArchiveCatalog::iterator CatalogIter;
typedef wxArchiveIterator<InputStreamT,
for (CatalogIter it = cat.begin(); it != cat.end(); ++it)
CPPUNIT_ASSERT(m_testEntries.count(it->second->GetName(wxPATH_UNIX)));
for (CatalogIter it = cat.begin(); it != cat.end(); ++it)
CPPUNIT_ASSERT(m_testEntries.count(it->second->GetName(wxPATH_UNIX)));
}
// try reading two entries at the same time
}
// try reading two entries at the same time
// take the last component of the name and append to the parent
name = test->getName();
string::size_type i = name.find_last_of(".:");
// take the last component of the name and append to the parent
name = test->getName();
string::size_type i = name.find_last_of(".:");
- name = parent + "." + (i != string::npos ? name.substr(i + 1) : name);
+ if (i != string::npos)
+ name = name.substr(i + 1);
+ name = parent + "." + name;
// drop the 1st component from the display and indent
if (parent != "") {
// drop the 1st component from the display and indent
if (parent != "") {