~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to include/libtorrent/lazy_entry.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
#include <utility>
37
37
#include <vector>
38
 
#include <iosfwd>
39
38
#include <string>
40
39
#include "libtorrent/config.hpp"
41
40
#include "libtorrent/assert.hpp"
42
41
#include "libtorrent/size_type.hpp"
43
42
 
 
43
#if TORRENT_USE_IOSTREAM
 
44
#include <iosfwd>
 
45
#endif
 
46
 
44
47
namespace libtorrent
45
48
{
46
49
        struct lazy_entry;
50
53
        // return 0 = success
51
54
        TORRENT_EXPORT int lazy_bdecode(char const* start, char const* end, lazy_entry& ret, int depth_limit = 1000);
52
55
 
 
56
        struct lazy_dict_entry;
 
57
 
53
58
        struct TORRENT_EXPORT lazy_entry
54
59
        {
55
60
                enum entry_type_t
128
133
                lazy_entry const* dict_find_dict(char const* name) const;
129
134
                lazy_entry const* dict_find_list(char const* name) const;
130
135
                lazy_entry const* dict_find_string(char const* name) const;
 
136
                lazy_entry const* dict_find_int(char const* name) const;
131
137
 
132
 
                std::pair<std::string, lazy_entry const*> dict_at(int i) const
133
 
                {
134
 
                        TORRENT_ASSERT(m_type == dict_t);
135
 
                        TORRENT_ASSERT(i < m_size);
136
 
                        std::pair<char const*, lazy_entry> const& e = m_data.dict[i];
137
 
                        return std::make_pair(std::string(e.first, e.second.m_begin - e.first), &e.second);
138
 
                }
 
138
                std::pair<std::string, lazy_entry const*> dict_at(int i) const;
139
139
 
140
140
                int dict_size() const
141
141
                {
215
215
                entry_type_t m_type;
216
216
                union data_t
217
217
                {
218
 
                        std::pair<char const*, lazy_entry>* dict;
 
218
                        lazy_dict_entry* dict;
219
219
                        lazy_entry* list;
220
220
                        char const* start;
221
221
                } m_data;
 
222
 
222
223
                int m_size; // if list or dictionary, the number of items
223
224
                int m_capacity; // if list or dictionary, allocated number of items
224
225
                // used for dictionaries and lists to record the range
225
226
                // in the original buffer they are based on
226
227
                char const* m_begin;
227
228
                char const* m_end;
228
 
        };
229
 
 
 
229
 
 
230
                // non-copyable
 
231
                lazy_entry(lazy_entry const&);
 
232
                lazy_entry const& operator=(lazy_entry const&);
 
233
        };
 
234
 
 
235
        struct lazy_dict_entry
 
236
        {
 
237
                char const* name;
 
238
                lazy_entry val;
 
239
        };
 
240
 
 
241
        TORRENT_EXPORT std::string print_entry(lazy_entry const& e);
 
242
#if TORRENT_USE_IOSTREAM
230
243
        TORRENT_EXPORT std::ostream& operator<<(std::ostream& os, lazy_entry const& e);
 
244
#endif
231
245
 
232
246
}
233
247