~ubuntu-branches/ubuntu/raring/clucene-core/raring-proposed

« back to all changes in this revision

Viewing changes to src/contribs-lib/CLucene/util/streamarray.h

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-08-11 09:33:38 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120811093338-fgrx41ftqew3qt6a
Tags: 2.3.3.4-1
* New upstream release (Closes: #661703).
* Convert package to multiarch.
* Drop obsolete patches:
  - 01_add_missing_include_bug505667.diff
  - 02_posixness_fix_bug530308.diff
* Add patches:
  - Fixing_ZLIB_configuration_in_shared_CMakeLists.patch
  - Fix-pkgconfig-file-by-adding-clucene-shared-library.patch
  - Install-contribs-lib.patch
  - multiarch.patch
* Update debian/compat: bump to 8.
* Update debian/control:
  - update build dependencies (add cmake, libboost-dev and libz-dev).
  - bump Standards-Version to 3.9.3.
  - rename packages due to ABI bump: libclucene0ldbl -> libclucene-core1.
  - add libclucene-contribs1 package.
* Update debian/rules:
  - rewrite to use CMake.
  - add multiarch support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*------------------------------------------------------------------------------
 
2
* Copyright (C) 2009 Isidor Zeuner
 
3
 
4
* Distributable under the terms of either the Apache License (Version 2.0) or 
 
5
* the GNU Lesser General Public License, as specified in the COPYING file.
 
6
------------------------------------------------------------------------------*/
 
7
#ifndef CLUCENE_UTIL_STREAMARRAY_H
 
8
#define CLUCENE_UTIL_STREAMARRAY_H
 
9
 
 
10
#include <cstring>
 
11
#include "CLucene/util/CLStreams.h"
 
12
#include "CLucene/util/Array.h"
 
13
 
 
14
CL_NS_DEF(util)
 
15
 
 
16
template<typename element>
 
17
ValueArray<element> streamArray(CL_NS(util)::CLStream<element>* stored) {
 
18
        size_t const block_size = 4096;
 
19
        element const* retrieved;
 
20
        ValueArray<element> result(0);
 
21
        size_t available;
 
22
        size_t offset = 0;
 
23
        do {
 
24
                available = stored->read(retrieved, block_size, block_size);
 
25
                result.resize(result.length + sizeof(element) * available);
 
26
                memcpy(result.values + offset, retrieved, sizeof(element) * available);
 
27
                offset += available;
 
28
        } while (block_size == available);
 
29
        return result;
 
30
}
 
31
CL_NS_END
 
32
#endif