/usr/include/omniORB4/omniutilities.h is in libomniorb4-dev 4.2.2-0.8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | // -*- Mode: C++; -*-
// Package : omniORB2
// omniutilities.h Created on: 11/98
// Author : David Riddoch
//
// Copyright (C) 1996-1999 AT&T Laboratories Cambridge
//
// This file is part of the omniORB library
//
// The omniORB library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library. If not, see http://www.gnu.org/licenses/
//
//
// Description:
// *** PROPRIETARY INTERFACE ***
//
#ifndef __OMNIUTILITIES_H__
#define __OMNIUTILITIES_H__
template <class InputIterator, class OutputIterator>
inline OutputIterator omnicopy(InputIterator first, InputIterator last,
OutputIterator result)
{
while( first != last ) *result++ = *first++;
return result;
}
//: A vector template.
// This is similar to the STL vector type, but not as good! In
// particular objects of type T are constructed when they are
// allocated - not when they are first inserted. However this makes
// little difference for primitive types (eg. pointers). The
// interface mimics that of STL vector so that transition to STL will
// be simple.
template <class T>
class omnivector {
public:
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef T* iterator;
typedef const T* const_iterator;
typedef size_t size_type;
inline omnivector() : start(0), finish(0), end_of_storage(0) {}
inline omnivector(size_type n, const T& value = T())
: start(0), finish(0), end_of_storage(0) {
reserve(n);
while( n-- ) push_back(value);
}
inline ~omnivector() { deallocate(); }
inline void reserve(size_type n) {
if( capacity() < n ) {
size_type old_size = size();
iterator tmp = allocate(n);
omnicopy(start, finish, tmp);
deallocate();
start = tmp;
finish = start + old_size;
end_of_storage = start + n;
}
}
inline iterator begin() { return start; }
inline const_iterator begin() const { return start; }
inline iterator end() { return finish; }
inline const_iterator end() const { return finish; }
inline size_type size() const { return size_type(finish - start); }
inline size_type capacity() const {
return size_type(end_of_storage - start);
}
inline int empty() const { return start == finish; }
inline reference operator[](size_type n) { return *(start + n); }
inline const_reference operator[](size_type n) const { return *(start + n); }
inline reference front() { return *start; }
inline reference back() { return *(finish - 1); }
inline void push_back(const T& x) {
if( finish == end_of_storage ) more();
*finish++ = x;
}
inline void pop_back() { finish--; }
inline iterator erase(iterator position) {
if( position + 1 != finish )
omnicopy(position + 1, finish, position);
finish--;
return position;
}
inline iterator erase(iterator first, iterator last) {
iterator i = omnicopy(last, finish, first);
finish -= (last - first);
return first;
}
#if 0
void resize(size_type new_size, const T& x) {
if (new_size < size())
erase(begin() + new_size, end());
else
insert(end(), new_size - size(), x);
}
void resize(size_type new_size) { resize(new_size, T()); }
#endif
private:
inline void more() { reserve(size() ? size() * 2 : 1); }
inline void deallocate() { if( start ) delete[] start; }
inline iterator allocate(size_type n) {
return new value_type[n];
}
omnivector<T>& operator=(const omnivector<T>& x);
//?? Not yet implemented
iterator start;
iterator finish;
iterator end_of_storage;
};
#endif // __OMNIUTILITIES_H__
|