EstervQrCode 1.1.1
Library for qr code manipulation
cvstd.hpp
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
8 //
9 //
10 // License Agreement
11 // For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15 // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
16 // Third party copyrights are property of their respective owners.
17 //
18 // Redistribution and use in source and binary forms, with or without modification,
19 // are permitted provided that the following conditions are met:
20 //
21 // * Redistribution's of source code must retain the above copyright notice,
22 // this list of conditions and the following disclaimer.
23 //
24 // * Redistribution's in binary form must reproduce the above copyright notice,
25 // this list of conditions and the following disclaimer in the documentation
26 // and/or other materials provided with the distribution.
27 //
28 // * The name of the copyright holders may not be used to endorse or promote products
29 // derived from this software without specific prior written permission.
30 //
31 // This software is provided by the copyright holders and contributors "as is" and
32 // any express or implied warranties, including, but not limited to, the implied
33 // warranties of merchantability and fitness for a particular purpose are disclaimed.
34 // In no event shall the Intel Corporation or contributors be liable for any direct,
35 // indirect, incidental, special, exemplary, or consequential damages
36 // (including, but not limited to, procurement of substitute goods or services;
37 // loss of use, data, or profits; or business interruption) however caused
38 // and on any theory of liability, whether in contract, strict liability,
39 // or tort (including negligence or otherwise) arising in any way out of
40 // the use of this software, even if advised of the possibility of such damage.
41 //
42 //M*/
43 
44 #ifndef OPENCV_CORE_CVSTD_HPP
45 #define OPENCV_CORE_CVSTD_HPP
46 
47 #ifndef __cplusplus
48 # error cvstd.hpp header must be compiled as C++
49 #endif
50 
51 #include "opencv2/core/cvdef.h"
52 #include <cstddef>
53 #include <cstring>
54 #include <cctype>
55 
56 #include <string>
57 
58 // import useful primitives from stl
59 # include <algorithm>
60 # include <utility>
61 # include <cstdlib> //for abs(int)
62 # include <cmath>
63 
64 namespace cv
65 {
66  static inline uchar abs(uchar a) { return a; }
67  static inline ushort abs(ushort a) { return a; }
68  static inline unsigned abs(unsigned a) { return a; }
69  static inline uint64 abs(uint64 a) { return a; }
70 
71  using std::min;
72  using std::max;
73  using std::abs;
74  using std::swap;
75  using std::sqrt;
76  using std::exp;
77  using std::pow;
78  using std::log;
79 }
80 
81 #include "cvstd_wrapper.hpp"
82 
83 namespace cv {
84 
87 
89 
96 CV_EXPORTS void* fastMalloc(size_t bufSize);
97 
105 CV_EXPORTS void fastFree(void* ptr);
106 
110 template<typename _Tp> class Allocator
111 {
112 public:
113  typedef _Tp value_type;
114  typedef value_type* pointer;
115  typedef const value_type* const_pointer;
117  typedef const value_type& const_reference;
118  typedef size_t size_type;
119  typedef ptrdiff_t difference_type;
120  template<typename U> class rebind { typedef Allocator<U> other; };
121 
122  explicit Allocator() {}
124  explicit Allocator(Allocator const&) {}
125  template<typename U>
126  explicit Allocator(Allocator<U> const&) {}
127 
128  // address
129  pointer address(reference r) { return &r; }
131 
132  pointer allocate(size_type count, const void* =0) { return reinterpret_cast<pointer>(fastMalloc(count * sizeof (_Tp))); }
134 
135  void construct(pointer p, const _Tp& v) { new(static_cast<void*>(p)) _Tp(v); }
136  void destroy(pointer p) { p->~_Tp(); }
137 
138  size_type max_size() const { return cv::max(static_cast<_Tp>(-1)/sizeof(_Tp), 1); }
139 };
140 
142 
143 
146 
148 
149 class CV_EXPORTS FileNode; //for string constructor from FileNode
150 
152 
153 #ifndef OPENCV_DISABLE_STRING_LOWER_UPPER_CONVERSIONS
154 
156 namespace details {
157 // std::tolower is int->int
158 static inline char char_tolower(char ch)
159 {
160  return (char)std::tolower((int)ch);
161 }
162 // std::toupper is int->int
163 static inline char char_toupper(char ch)
164 {
165  return (char)std::toupper((int)ch);
166 }
167 } // namespace details
169 
170 static inline std::string toLowerCase(const std::string& str)
171 {
172  std::string result(str);
173  std::transform(result.begin(), result.end(), result.begin(), details::char_tolower);
174  return result;
175 }
176 
177 static inline std::string toUpperCase(const std::string& str)
178 {
179  std::string result(str);
180  std::transform(result.begin(), result.end(), result.begin(), details::char_toupper);
181  return result;
182 }
183 
184 #endif // OPENCV_DISABLE_STRING_LOWER_UPPER_CONVERSIONS
185 
187 } // cv
188 
189 #endif //OPENCV_CORE_CVSTD_HPP
Definition: cvstd.hpp:120
Definition: cvstd.hpp:111
size_t size_type
Definition: cvstd.hpp:118
ptrdiff_t difference_type
Definition: cvstd.hpp:119
_Tp value_type
Definition: cvstd.hpp:113
Allocator(Allocator< U > const &)
Definition: cvstd.hpp:126
const value_type & const_reference
Definition: cvstd.hpp:117
Allocator(Allocator const &)
Definition: cvstd.hpp:124
size_type max_size() const
Definition: cvstd.hpp:138
const value_type * const_pointer
Definition: cvstd.hpp:115
pointer address(reference r)
Definition: cvstd.hpp:129
pointer allocate(size_type count, const void *=0)
Definition: cvstd.hpp:132
void construct(pointer p, const _Tp &v)
Definition: cvstd.hpp:135
Allocator()
Definition: cvstd.hpp:122
void destroy(pointer p)
Definition: cvstd.hpp:136
value_type * pointer
Definition: cvstd.hpp:114
void deallocate(pointer p, size_type)
Definition: cvstd.hpp:133
value_type & reference
Definition: cvstd.hpp:116
const_pointer address(const_reference r)
Definition: cvstd.hpp:130
~Allocator()
Definition: cvstd.hpp:123
T exp(T... args)
static std::string toLowerCase(const std::string &str)
Definition: cvstd.hpp:170
std::string String
Definition: cvstd.hpp:151
static std::string toUpperCase(const std::string &str)
Definition: cvstd.hpp:177
class CV_EXPORTS FileNode
Definition: cvstd.hpp:149
int count
Definition: core_c.h:1413
const CvArr const CvArr CvArr * result
Definition: core_c.h:1423
unsigned char uchar
Definition: interface.h:51
unsigned short ushort
Definition: interface.h:52
uint64_t uint64
Definition: interface.h:62
softfloat abs(softfloat a)
Absolute value.
Definition: softfloat.hpp:444
softfloat max(const softfloat &a, const softfloat &b)
Definition: softfloat.hpp:440
#define CV_EXPORTS
Definition: cvdef.h:435
CV_EXPORTS void * fastMalloc(size_t bufSize)
Allocates an aligned memory buffer.
CV_EXPORTS void fastFree(void *ptr)
Deallocates a memory buffer.
CvRect r
Definition: imgproc_c.h:984
T log(T... args)
T max(T... args)
T min(T... args)
"black box" representation of the file storage associated with a file on disk.
Definition: calib3d.hpp:441
static uchar abs(uchar a)
Definition: cvstd.hpp:66
T pow(T... args)
T sqrt(T... args)
T swap(T... args)
T tolower(T... args)
T toupper(T... args)
T transform(T... args)