~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to libamf/buffer.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
//   Copyright (C) 2008 Free Software Foundation, Inc.
 
3
// 
 
4
// This program is free software; you can redistribute it and/or modify
 
5
// it under the terms of the GNU General Public License as published by
 
6
// the Free Software Foundation; either version 3 of the License, or
 
7
// (at your option) any later version.
 
8
// 
 
9
// This program is distributed in the hope that it will be useful,
 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
// GNU General Public License for more details.
 
13
//
 
14
// You should have received a copy of the GNU General Public License
 
15
// along with this program; if not, write to the Free Software
 
16
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
//
 
18
 
 
19
#ifndef __BUFFER_H__
 
20
#define __BUFFER_H__ 1
 
21
 
 
22
#include <boost/cstdint.hpp>
 
23
#include <string>
 
24
 
 
25
#include "getclocktime.hpp"
 
26
#include "amf.h"
 
27
#include "element.h"
 
28
#include "network.h"
 
29
#include "dsodefs.h"
 
30
 
 
31
// _definst_ is the default instance name
 
32
namespace amf
 
33
{
 
34
 
 
35
class DSOEXPORT Buffer 
 
36
{
 
37
public:
 
38
    Buffer();
 
39
    // Create with a size other than the default
 
40
    Buffer(size_t nbytes);
 
41
    
 
42
    // Delete the allocate memory
 
43
    ~Buffer();
 
44
    void clear();
 
45
    bool empty() { return (_seekptr)?true:false; };
 
46
 
 
47
    // Resize the buffer that holds the data
 
48
    void *resize();
 
49
    void *resize(size_t nbytes);
 
50
 
 
51
    // Put data into the buffer. This overwrites all data, and resets the seek ptr.
 
52
    void copy(gnash::Network::byte_t *data, size_t nbytes);
 
53
    void copy(gnash::Network::byte_t *data) { copy(data, _nbytes); };
 
54
    void copy(const std::string &str);
 
55
    void copy(double num);
 
56
    void copy(boost::uint16_t length);
 
57
    void copy(gnash::Network::byte_t byte);
 
58
//    void copy(bool);
 
59
//     void copy(boost::uint32_t val);
 
60
//     void copy(Element::amf_type_e type);
 
61
 
 
62
    // Append data to the existing data in the buffer. This assume the
 
63
    // buffer has been sized to hold the data as it is appended.
 
64
    gnash::Network::byte_t *append(Buffer *buf);
 
65
    gnash::Network::byte_t *append(Buffer &buf);
 
66
    gnash::Network::byte_t *append(boost::uint32_t val);
 
67
    gnash::Network::byte_t *append(bool);
 
68
    gnash::Network::byte_t *append(double num);
 
69
    gnash::Network::byte_t *append(Element::amf0_type_e type);
 
70
    gnash::Network::byte_t *append(boost::uint16_t length);
 
71
    gnash::Network::byte_t *append(gnash::Network::byte_t *data, size_t nbytes);
 
72
    gnash::Network::byte_t *append(gnash::Network::byte_t byte);
 
73
    gnash::Network::byte_t *append(const std::string &str);
 
74
 
 
75
    // Find a byte in the buffer
 
76
//    Network::byte_t *find(char c);
 
77
    gnash::Network::byte_t *find(gnash::Network::byte_t b);
 
78
    gnash::Network::byte_t *find(gnash::Network::byte_t *b, size_t size);
 
79
    
 
80
    // Drop a byte or range of characters without resizing
 
81
//    Network::byte_t *remove(char c);
 
82
    gnash::Network::byte_t *remove(gnash::Network::byte_t c);
 
83
    gnash::Network::byte_t *remove(int x);
 
84
    gnash::Network::byte_t *remove(int x, int y);
 
85
    
 
86
    // Accessors
 
87
    gnash::Network::byte_t *begin() { return _ptr ; };
 
88
    gnash::Network::byte_t *end() { return _ptr + _nbytes; };
 
89
    gnash::Network::byte_t *reference() { return _ptr; }
 
90
    size_t size() { return _nbytes; }
 
91
    void setSize(size_t nbytes) { _nbytes = nbytes; };
 
92
    
 
93
    // make ourselves be able to be copied.
 
94
    Buffer &operator=(Buffer *buf);
 
95
    Buffer &operator=(Buffer &buf);
 
96
 
 
97
    // Test against other buffers
 
98
    bool operator==(Buffer *buf);
 
99
    bool operator==(Buffer &buf);
 
100
    Buffer &operator+=(Buffer *buf);
 
101
    Buffer &operator+=(gnash::Network::byte_t byte);
 
102
    Buffer &operator+=(char byte);
 
103
    Buffer &operator+=(Buffer &buf);
 
104
    gnash::Network::byte_t operator[](int x) { return *(_ptr + x); };
 
105
    gnash::Network::byte_t *at(int x) { return _ptr + x; };
 
106
//    Buffer *hex2mem(const char *str);
 
107
 
 
108
    // How much room is left in the buffer past the seek pointer. This is
 
109
    // primarily used to see if the buffer is full populated with data.
 
110
    size_t spaceLeft() { return (_nbytes - (_seekptr - _ptr)); };
 
111
    
 
112
    // debug stuff, not need for running Cygnal
 
113
    void dump();
 
114
  protected:
 
115
    void *init(size_t nbytes);
 
116
    gnash::Network::byte_t *_seekptr;
 
117
    gnash::Network::byte_t *_ptr;
 
118
    size_t         _nbytes;
 
119
#ifdef USE_STATS_BUFFERS
 
120
    struct timespec _stamp;     // used for timing how long data stays in the queue.
 
121
#endif
 
122
};
 
123
 
 
124
 
 
125
} // end of amf namespace
 
126
 
 
127
#endif // end of __BUFFER_H__
 
128
 
 
129
// local Variables:
 
130
// mode: C++
 
131
// indent-tabs-mode: t
 
132
// End: