GraphLab: Distributed Graph-Parallel API  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
resizing_array_sink.hpp
1 /**
2  * Copyright (c) 2009 Carnegie Mellon University.
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an "AS
13  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14  * express or implied. See the License for the specific language
15  * governing permissions and limitations under the License.
16  *
17  * For more about this software visit:
18  *
19  * http://www.graphlab.ml.cmu.edu
20  *
21  */
22 
23 
24 #ifndef GRAPHLAB_RESIZING_COUNTING_SINK
25 #define GRAPHLAB_RESIZING_COUNTING_SINK
26 
27 #include <graphlab/util/charstream.hpp>
28 
29 namespace graphlab {
30 
31  typedef charstream_impl::resizing_array_sink<false> resizing_array_sink;
32 
33  /**
34  Wraps a resizing array sink.
35  */
37  private:
38  resizing_array_sink* ras;
39  public:
40 
41 
42  typedef resizing_array_sink::char_type char_type;
43  typedef resizing_array_sink::category category;
44 
45  inline resizing_array_sink_ref(resizing_array_sink& ref): ras(&ref) { }
46 
48  ras(other.ras) { }
49 
50  inline size_t size() const { return ras->size(); }
51  inline char* c_str() { return ras->c_str(); }
52 
53  inline void clear() { ras->clear(); }
54  /** the optimal buffer size is 0. */
55  inline std::streamsize optimal_buffer_size() const {
56  return ras->optimal_buffer_size();
57  }
58 
59  inline void relinquish() { ras->relinquish(); }
60 
61  inline void advance(std::streamsize n) { ras->advance(n); }
62 
63 
64  inline std::streamsize write(const char* s, std::streamsize n) {
65  return ras->write(s, n);
66  }
67  };
68 
69 }
70 #endif
71