OpenCV453
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
64namespace 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
83namespace cv {
84
87
89
96CV_EXPORTS void* fastMalloc(size_t bufSize);
97
105CV_EXPORTS void fastFree(void* ptr);
106
110template<typename _Tp> class Allocator
111{
112public:
113 typedef _Tp value_type;
114 typedef value_type* pointer;
115 typedef const value_type* const_pointer;
116 typedef value_type& reference;
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() {}
123 ~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; }
130 const_pointer address(const_reference r) { return &r; }
131
132 pointer allocate(size_type count, const void* =0) { return reinterpret_cast<pointer>(fastMalloc(count * sizeof (_Tp))); }
133 void deallocate(pointer p, size_type) { fastFree(p); }
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
144
147
149
150class CV_EXPORTS FileNode; //for string constructor from FileNode
151
152typedef std::string String;
153
154#ifndef OPENCV_DISABLE_STRING_LOWER_UPPER_CONVERSIONS
155
157namespace details {
158// std::tolower is int->int
159static inline char char_tolower(char ch)
160{
161 return (char)std::tolower((int)ch);
162}
163// std::toupper is int->int
164static inline char char_toupper(char ch)
165{
166 return (char)std::toupper((int)ch);
167}
168} // namespace details
170
171static inline std::string toLowerCase(const std::string& str)
172{
173 std::string result(str);
174 std::transform(result.begin(), result.end(), result.begin(), details::char_tolower);
175 return result;
176}
177
178static inline std::string toUpperCase(const std::string& str)
179{
180 std::string result(str);
181 std::transform(result.begin(), result.end(), result.begin(), details::char_toupper);
182 return result;
183}
184
185#endif // OPENCV_DISABLE_STRING_LOWER_UPPER_CONVERSIONS
186
188} // cv
189
190#endif //OPENCV_CORE_CVSTD_HPP
Definition: cvstd.hpp:120
Definition: cvstd.hpp:111
CV_EXPORTS_W void transform(InputArray src, OutputArray dst, InputArray m)
Performs the matrix transformation of every array element.
CV_EXPORTS_W void max(InputArray src1, InputArray src2, OutputArray dst)
Calculates per-element maximum of two arrays or an array and a scalar.
CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst)
Calculates a square root of array elements.
CV_EXPORTS_W void exp(InputArray src, OutputArray dst)
Calculates the exponent of every array element.
CV_EXPORTS_W void pow(InputArray src, double power, OutputArray dst)
Raises every array element to a power.
CV_EXPORTS_W void min(InputArray src1, InputArray src2, OutputArray dst)
Calculates per-element minimum of two arrays or an array and a scalar.
CV_EXPORTS_W void log(InputArray src, OutputArray dst)
Calculates the natural logarithm of every array element.
softfloat abs(softfloat a)
Absolute value
Definition: softfloat.hpp:444
CV_EXPORTS void * fastMalloc(size_t bufSize)
Allocates an aligned memory buffer.
CV_EXPORTS void fastFree(void *ptr)
Deallocates a memory buffer.
CV_EXPORTS void swap(Mat &a, Mat &b)
Swaps two matrices
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75