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;
#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);
}
-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));
#else
template <class Arc, class T = typename Arc::entry_type*>
#endif
-class WXDLLIMPEXP_BASE wxArchiveIterator
+class wxArchiveIterator
{
public:
typedef std::input_iterator_tag iterator_category;
return it;
}
- 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 {
return !(*this == j);
}
#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
-bool wxZipEntry::IsText() const
+inline bool wxZipEntry::IsText() const
{
return (m_InternalAttributes & TEXT_ATTR) != 0;
}
-bool wxZipEntry::IsDir() const
+inline bool wxZipEntry::IsDir() const
{
return (m_ExternalAttributes & wxZIP_A_SUBDIR) != 0;
}
-bool wxZipEntry::IsReadOnly() const
+inline bool wxZipEntry::IsReadOnly() const
{
return (m_ExternalAttributes & wxZIP_A_RDONLY) != 0;
}
-bool wxZipEntry::IsMadeByUnix() const
+inline bool wxZipEntry::IsMadeByUnix() const
{
const int pattern =
(1 << wxZIP_SYSTEM_OPENVMS) |
|| ((pattern >> m_SystemMadeBy) & 1);
}
-void wxZipEntry::SetIsText(bool isText)
+inline void wxZipEntry::SetIsText(bool isText)
{
if (isText)
m_InternalAttributes |= TEXT_ATTR;
m_InternalAttributes &= ~TEXT_ATTR;
}
-void wxZipEntry::SetIsReadOnly(bool isReadOnly)
+inline void wxZipEntry::SetIsReadOnly(bool isReadOnly)
{
if (isReadOnly)
SetMode(GetMode() & ~0222);
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);
#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
{
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; }
private:
wxDateTime m_dt;
size_t m_len;
- const char *m_data;
+ char *m_data;
wxString m_comment;
bool m_isText;
};
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;
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 };
return size;
}
-void TestOutputStream::GetData(const char*& data, size_t& size)
+void TestOutputStream::GetData(char*& data, size_t& size)
{
data = m_data;
size = m_size;
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; }
int m_options;
size_t m_pos;
size_t m_size;
- const char *m_data;
+ char *m_data;
};
TestInputStream::TestInputStream(const TestInputStream& in)
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::SetData(TestOutputStream& out)
{
- delete [] (char*) m_data;
+ delete [] m_data;
m_options = out.GetOptions();
out.GetData(m_data, m_size);
Rewind();
{
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);
}
{
auto_ptr<InputStreamT> arcIn(m_factory->NewStream(in));
auto_ptr<OutputStreamT> arcOut(m_factory->NewStream(out));
- ;
+ EntryT *pEntry;
const wxString deleteName = _T("bin/bin1000");
const wxString renameFrom = _T("zero/zero1024");
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
}
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,
}
CPPUNIT_ASSERT_MESSAGE("CopyEntry" + error_context,
- arcOut->CopyEntry(pEntry->release(), *arcIn));
+ arcOut->CopyEntry(entry.release(), *arcIn));
}
}
- delete pEntry;
-
// 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());
- 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);
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,
for (CatalogIter it = cat.begin(); it != cat.end(); ++it)
CPPUNIT_ASSERT(m_testEntries.count(it->second->GetName(wxPATH_UNIX)));
+#endif
}
// try reading two entries at the same time