56#include <visp3/core/vpDebug.h>
57#include <visp3/core/vpEndian.h>
58#include <visp3/core/vpIoException.h>
59#include <visp3/core/vpIoTools.h>
60#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
75#if defined(__APPLE__) && defined(__MACH__)
76#include <TargetConditionals.h>
81# define PATH_MAX _MAX_PATH
97#if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
98#if (TARGET_OS_IOS == 0) && !defined(__ANDROID__)
99void replaceAll(std::string &str,
const std::string &search,
const std::string &replace)
101 size_t start_pos = 0;
102 while ((start_pos = str.find(search, start_pos)) != std::string::npos) {
103 str.replace(start_pos, search.length(), replace);
104 start_pos += replace.length();
111std::string <rim(std::string &s)
113#if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
114 s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](
int c) { return !std::isspace(c); }));
116 s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
121std::string &rtrim(std::string &s)
123#if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
124 s.erase(std::find_if(s.rbegin(), s.rend(), [](
int c) { return !std::isspace(c); }).base(), s.end());
126 s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
137 static std::string build_info =
138#include "version_string.inc"
196#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
197 std::string username;
199 return "/tmp/" + username;
200#elif defined(_WIN32) && !defined(WINRT)
203 TCHAR lpTempPathBuffer[MAX_PATH];
204 DWORD dwRetVal = GetTempPath(MAX_PATH , lpTempPathBuffer );
205 if (dwRetVal > MAX_PATH || (dwRetVal == 0)) {
208 std::string temp_path(lpTempPathBuffer);
209 if (!temp_path.empty()) {
210 if (temp_path.back() ==
'\\') {
211 temp_path.resize(temp_path.size() - 1);
215 temp_path =
"C:\temp";
272#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
274 char *_username =
::getenv(
"LOGNAME");
276 username =
"unknown";
279 username = _username;
283 unsigned int info_buffer_size = 1024;
284 TCHAR *infoBuf =
new TCHAR[info_buffer_size];
285 DWORD bufCharCount = (DWORD)info_buffer_size;
287 if (!GetUserName(infoBuf, &bufCharCount)) {
288 username =
"unknown";
295 username =
"unknown";
298 username =
"unknown";
318 std::string username;
355#if defined(_WIN32) && defined(WINRT)
357 "implemented on Universal Windows Platform"));
361 char *_value =
::getenv(env.c_str());
380void vpIoTools::getVersion(
const std::string &version,
unsigned int &major,
unsigned int &minor,
unsigned int &patch)
382 if (version.size() == 0) {
387 size_t major_pos = version.find(
'.');
388 std::string major_str = version.substr(0, major_pos);
389 major =
static_cast<unsigned>(atoi(major_str.c_str()));
391 if (major_pos != std::string::npos) {
392 size_t minor_pos = version.find(
'.', major_pos + 1);
393 std::string minor_str = version.substr(major_pos + 1, (minor_pos - (major_pos + 1)));
394 minor =
static_cast<unsigned>(atoi(minor_str.c_str()));
396 if (minor_pos != std::string::npos) {
397 std::string patch_str = version.substr(minor_pos + 1);
398 patch =
static_cast<unsigned>(atoi(patch_str.c_str()));
422#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
424#elif defined(_WIN32) && defined(__MINGW32__)
430 if (dirname.empty()) {
434 std::string _dirname =
path(dirname);
436#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
437 if (stat(_dirname.c_str(), &stbuf) != 0)
438#elif defined(_WIN32) && defined(__MINGW32__)
443 _dirname = _dirname.substr(0, _dirname.size() - 1);
444 if (stat(_dirname.c_str(), &stbuf) != 0)
446 if (_stat(_dirname.c_str(), &stbuf) != 0)
451#if defined(_WIN32) || (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
452 if ((stbuf.st_mode & S_IFDIR) == 0)
457#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
458 if ((stbuf.st_mode & S_IWUSR) == 0)
460 if ((stbuf.st_mode & S_IWRITE) == 0)
482#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
485 std::string _filename =
path(fifofilename);
486 if (stat(_filename.c_str(), &stbuf) != 0) {
489 if ((stbuf.st_mode & S_IFIFO) == 0) {
492 if ((stbuf.st_mode & S_IRUSR) == 0)
504#ifndef DOXYGEN_SHOULD_SKIP_THIS
507int vpIoTools::mkdir_p(
const char *path,
int mode)
510 const size_t len = strlen(
path);
511 char _path[PATH_MAX];
514 std::fill(_path, _path + PATH_MAX, 0);
517 if (len >
sizeof(_path) - 1) {
518 errno = ENAMETOOLONG;
525 for (
char *p = _path + 1; *p; p++) {
530#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
531 if (mkdir(_path,
static_cast<mode_t
>(mode)) != 0)
544#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
545 if (mkdir(_path,
static_cast<mode_t
>(mode)) != 0)
547 if (_mkdir(_path) != 0)
572#if ((!defined(__unix__) && !defined(__unix) && (!defined(__APPLE__) || !defined(__MACH__)))) && !defined(_WIN32)
573 std::cerr <<
"Unsupported platform for vpIoTools::makeDirectory()!" << std::endl;
577#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
579#elif defined(_WIN32) && defined(__MINGW32__)
585 if (dirname.empty()) {
589 std::string _dirname =
path(dirname);
591#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
592 if (stat(_dirname.c_str(), &stbuf) != 0)
593#elif defined(_WIN32) && defined(__MINGW32__)
594 if (stat(_dirname.c_str(), &stbuf) != 0)
596 if (_stat(_dirname.c_str(), &stbuf) != 0)
599 if (vpIoTools::mkdir_p(_dirname.c_str(), 0755) != 0) {
623#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
628 "Unable to create fifo file. '%s' is an existing directory.", fifoname.c_str()));
641 else if (mkfifo(fifoname.c_str(), 0666) < 0) {
650#if defined(_WIN32) && !defined(WINRT)
654 if (UuidCreate(&uuid) != RPC_S_OK) {
659 if (UuidToString(&uuid, &stringUuid) != RPC_S_OK) {
663 return reinterpret_cast<char *
>(stringUuid);
730#if defined(WINRT) || !defined(_WIN32) && \
731 !(defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
735 std::string dirname_cpy = std::string(dirname);
736 std::string correctEnding =
"XXXXXX";
738 size_t endingLength = correctEnding.length();
739 size_t dirNameLength = dirname_cpy.length();
743 if (endingLength > dirNameLength) {
745 "Unable to create temp directory '%s'. It should end with XXXXXX.", dirname_cpy.c_str()));
748 if (dirname.compare(dirNameLength - endingLength, endingLength, correctEnding) != 0) {
750 "Unable to create temp directory '%s'. It should end with XXXXXX.", dirname_cpy.c_str()));
753#if defined(_WIN32) && !defined(WINRT)
755 dirname_cpy = dirname_cpy.substr(0, dirname_cpy.rfind(correctEnding));
757 dirname_cpy = dirname_cpy + getUuid();
762#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
763 if (dirname_cpy.at(dirname_cpy.length() - 1) !=
'/') {
764 dirname_cpy = dirname_cpy +
"/";
766 dirname_cpy = dirname_cpy +
"XXXXXX";
767#elif defined(_WIN32) && !defined(WINRT)
772#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
773 char *dirname_char =
new char[dirname_cpy.length() + 1];
774 strcpy(dirname_char, dirname_cpy.c_str());
776 char *computedDirname = mkdtemp(dirname_char);
778 if (!computedDirname) {
779 delete[] dirname_char;
783 std::string res(computedDirname);
784 delete[] dirname_char;
786#elif defined(_WIN32) && !defined(WINRT)
804#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
810 if (filename.empty()) {
814 std::string _filename =
path(filename);
815#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
816 if (stat(_filename.c_str(), &stbuf) != 0)
818 if (_stat(_filename.c_str(), &stbuf) != 0)
823 if ((stbuf.st_mode & S_IFREG) == 0) {
826#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
827 if ((stbuf.st_mode & S_IRUSR) == 0)
829 if ((stbuf.st_mode & S_IREAD) == 0)
849#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
850#if TARGET_OS_IOS == 0
852 char cmd[FILENAME_MAX];
854 sprintf(cmd,
"cp -p %s %s", src.c_str(), dst.c_str());
865 char cmd[FILENAME_MAX];
869 sprintf(cmd,
"copy %s %s", src_.c_str(), dst_.c_str());
877 src.c_str(), dst.c_str()));
882#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
883#if TARGET_OS_IOS == 0
885 char cmd[FILENAME_MAX];
887 sprintf(cmd,
"cp -p -r %s %s", src.c_str(), dst.c_str());
898 char cmd[FILENAME_MAX];
902 sprintf(cmd,
"copy %s %s", src_.c_str(), dst_.c_str());
910 src.c_str(), dst.c_str()));
914 std::cout <<
"Cannot copy: " << src <<
" in " << dst << std::endl;
933#
if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
938 if (
::remove(file_or_dir.c_str()) != 0)
944#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
945#if TARGET_OS_IOS == 0
947 char cmd[FILENAME_MAX];
948 sprintf(cmd,
"rm -rf \"%s\"", file_or_dir.c_str());
949 int ret = system(cmd);
959 char cmd[FILENAME_MAX];
961 sprintf(cmd,
"rmdir /S /Q %s", file_or_dir_.c_str());
962 int ret = system(cmd);
969 file_or_dir.c_str()));
973 std::cout <<
"Cannot remove: " << file_or_dir << std::endl;
989 if (
::rename(oldfilename.c_str(), newfilename.c_str()) != 0)
1007 std::string
path(pathname);
1010 for (
unsigned int i = 0; i <
path.length(); i++)
1013#elif defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
1014 for (
unsigned int i = 0; i <
path.length(); i++)
1015 if (
path[i] ==
'\\')
1017#if TARGET_OS_IOS == 0
1022 wordexp_t exp_result;
1025 replaceAll(
path,
"'",
"'\\''");
1027 wordexp(std::string(
"'" +
path +
"'").c_str(), &exp_result, 0);
1028 path = exp_result.we_wordc == 1 ? exp_result.we_wordv[0] :
"";
1029 wordfree(&exp_result);
1050 std::ifstream confContent(
configFile.c_str(), std::ios::in);
1052 if (confContent.is_open()) {
1053 std::string line, var, val;
1054 long unsigned int k;
1056 std::string stop[3] = {
" ",
"\t",
"#"};
1057 while (std::getline(confContent, line)) {
1058 if ((line.compare(0, 1,
"#") != 0) && (line.size() > 2)) {
1061 k =
static_cast<unsigned long>(line.find(
" "));
1062 var = line.substr(0, k);
1065 for (
unsigned i = 0; i < 3; ++i)
1066 c =
vpMath::minimum(c,
static_cast<int>(line.find(stop[i],
static_cast<size_t>(k) +
static_cast<size_t>(1))));
1068 c =
static_cast<int>(line.size());
1069 long unsigned int c_ =
static_cast<long unsigned int>(c);
1070 val = line.substr(
static_cast<size_t>(k) +
static_cast<size_t>(1),
static_cast<size_t>(c_) -
static_cast<size_t>(k) -
static_cast<size_t>(1));
1077 confContent.close();
1095 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1098 value =
static_cast<float>(M_PI);
1100 value =
static_cast<float>(M_PI / 2.0);
1102 value =
static_cast<float>(-M_PI / 2.0);
1104 value =
static_cast<float>(atof(
configValues[k].c_str()));
1109 std::cout << var <<
" not found in config file" << std::endl;
1123 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1137 std::cout << var <<
" not found in config file" << std::endl;
1152 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1159 std::cout << var <<
" not found in config file" << std::endl;
1175 value =
static_cast<unsigned int>(v);
1222 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1229 std::cout << var <<
" not found in config file" << std::endl;
1247 const unsigned int &nRows)
1251 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1255 if (nCols != 0 && nRows != 0)
1256 value.
resize(nRows, nCols);
1257 size_t ind = 0, ind2;
1258 for (
unsigned int i = 0; i < value.
getRows(); ++i)
1259 for (
unsigned int j = 0; j < value.
getCols(); ++j) {
1262 if (nb.compare(
"PI") == 0)
1264 else if (nb.compare(
"PI/2") == 0)
1265 value[i][j] = M_PI / 2;
1266 else if (nb.compare(
"-PI/2") == 0)
1267 value[i][j] = -M_PI / 2;
1269 value[i][j] = atof(nb.c_str());
1275 std::cout << var <<
" not found in config file" << std::endl;
1293 else if (strFalse !=
"")
1308 if (std::fabs(val) < std::numeric_limits<double>::epsilon()) {
1310 sprintf(valC,
"%.3f", val);
1311 std::string valS(valC);
1367 std::string data_path;
1368 std::string file_to_test(
"mbt/cube.cao");
1369 std::string filename;
1373 filename = data_path +
"/" + file_to_test;
1377 filename = data_path +
"/" + file_to_test;
1381 filename = data_path +
"/" + file_to_test;
1386#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
1388 data_path =
"/usr/share/visp-images-data/ViSP-images";
1389 filename = data_path +
"/" + file_to_test;
1392 data_path =
"/usr/share/visp-images-data/visp-images";
1393 filename = data_path +
"/" + file_to_test;
1437 std::string sep =
"\\";
1438 std::string altsep =
"/";
1439 std::string extsep =
".";
1442 std::string sep =
"/";
1443 std::string altsep =
"";
1444 std::string extsep =
".";
1477 int sepIndex =
static_cast<int>(pathname.rfind(sep));
1478 if (!altsep.empty()) {
1479 int altsepIndex =
static_cast<int>(pathname.rfind(altsep));
1480 sepIndex = ((std::max))(sepIndex, altsepIndex);
1483 size_t dotIndex = pathname.rfind(extsep);
1484 if (dotIndex != std::string::npos) {
1486 size_t npos = std::string::npos;
1487 if ((sepIndex !=
static_cast<int>(npos) &&
static_cast<int>(dotIndex) > sepIndex) || sepIndex ==
static_cast<int>(npos)) {
1488 if (sepIndex ==
static_cast<int>(npos)) {
1491 size_t filenameIndex =
static_cast<size_t>(sepIndex) +
static_cast<size_t>(1);
1493 while (filenameIndex < dotIndex) {
1494 if (pathname.compare(filenameIndex, 1, extsep) != 0) {
1495 return pathname.substr(dotIndex);
1512 if (pathname.size() > 0) {
1516 if (index != std::string::npos) {
1517 return convertedPathname.substr(index + 1);
1520 return convertedPathname;
1535 size_t found = name.find_last_of(
".");
1536 std::string name_we = name.substr(0, found);
1575 size_t indexBegin = format.find_last_of(
'%');
1576 size_t indexEnd = format.find_first_of(
'd', indexBegin);
1577 size_t suffixLength = format.length() - indexEnd - 1;
1580 if (filename.length() <= suffixLength + indexBegin) {
1583 size_t indexLength = filename.length() - suffixLength - indexBegin;
1584 std::string indexSubstr = filename.substr(indexBegin, indexLength);
1585 std::istringstream ss(indexSubstr);
1588 if (ss.fail() || index < 0 || !ss.eof()) {
1593 char nameByFormat[FILENAME_MAX];
1594 sprintf(nameByFormat, format.c_str(), index);
1595 if (std::string(nameByFormat) != filename) {
1608 if (pathname.size() > 0) {
1612 if (index != std::string::npos) {
1613 return convertedPathname.substr(0, index);
1631#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
1632 std::string real_path_str = pathname;
1633 char *real_path = realpath(pathname.c_str(), NULL);
1636 real_path_str = real_path;
1639 return real_path_str;
1640#elif defined(_WIN32)
1641#if (!defined(WINRT))
1642 std::string real_path_str = pathname;
1644 TCHAR buffer[4096] = TEXT(
"");
1646 retval = GetFullPathName(pathname.c_str(), 4096, buffer, 0);
1648 real_path_str = buffer;
1650 return real_path_str;
1653 "Cannot get absolute path of %s: not implemented on "
1654 "Universal Windows Platform",
1672 if (child.size() == 0 && parent.size() == 0) {
1676 if (child.size() == 0) {
1680 if (parent.size() == 0) {
1687 std::stringstream ss;
1689 std::string stringSeparator;
1690 ss >> stringSeparator;
1692 std::string lastConvertedParentChar = convertedParent.substr(convertedParent.size() - 1);
1693 std::string firstConvertedChildChar = convertedChild.substr(0, 1);
1695 if (lastConvertedParentChar == stringSeparator) {
1696 convertedParent = convertedParent.substr(0, convertedParent.size() - 1);
1699 if (firstConvertedChildChar == stringSeparator) {
1700 convertedChild = convertedChild.substr(1);
1725 return path.size() > 0 && (
path.substr(0, 1) ==
"/" ||
path.substr(0, 1) ==
"\\");
1745 return (path1_normalize == path2_normalize);
1808#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
1809 return std::pair<std::string, std::string>(
"", pathname);
1811 const std::string sep =
"\\";
1812 const std::string sepsep =
"\\\\";
1813 const std::string altsep =
"/";
1815 if (pathname.size() > 1) {
1816 std::string normPathname = pathname;
1817 std::replace(normPathname.begin(), normPathname.end(), *altsep.c_str(), *sep.c_str());
1819 if (normPathname.substr(0, 2) == sepsep && normPathname.substr(2, 1) != sep) {
1824 size_t index = normPathname.find(sep, 2);
1825 if (index == std::string::npos) {
1826 return std::pair<std::string, std::string>(
"", pathname);
1829 size_t index2 = normPathname.find(sep, index + 1);
1832 if (index2 == index + 1) {
1833 return std::pair<std::string, std::string>(
"", pathname);
1836 if (index2 == std::string::npos) {
1837 index2 = pathname.size();
1840 return std::pair<std::string, std::string>(pathname.substr(0, index2), pathname.substr(index2));
1843 if (normPathname[1] ==
':') {
1844 return std::pair<std::string, std::string>(pathname.substr(0, 2), pathname.substr(2));
1848 return std::pair<std::string, std::string>(
"", pathname);
1902 size_t startIndex = 0;
1904 std::string chainToSplit = chain;
1905 std::vector<std::string> subChain;
1906 size_t sepIndex = chainToSplit.find(sep);
1908 while (sepIndex != std::string::npos) {
1909 std::string sub = chainToSplit.substr(startIndex, sepIndex);
1911 subChain.push_back(sub);
1912 chainToSplit = chainToSplit.substr(sepIndex + 1, chain.size() - 1);
1914 sepIndex = chainToSplit.find(sep);
1916 if (!chainToSplit.empty())
1917 subChain.push_back(chainToSplit);
1935 std::string dirName =
path(pathname);
1937#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
1939 std::vector<std::string> files;
1940 struct dirent **list = NULL;
1941 int filesCount = scandir(dirName.c_str(), &list, NULL, NULL);
1942 if (filesCount == -1) {
1945 for (
int i = 0; i < filesCount; i++) {
1946 std::string fileName = list[i]->d_name;
1947 if (fileName !=
"." && fileName !=
"..") {
1948 files.push_back(fileName);
1953 std::sort(files.begin(), files.end());
1956#elif defined(_WIN32)
1957#if (!defined(WINRT))
1959 std::vector<std::string> files;
1960 std::string fileMask = dirName;
1961 fileMask.append(
"\\*");
1962 WIN32_FIND_DATA FindFileData;
1963 HANDLE hFind = FindFirstFile(fileMask.c_str(), &FindFileData);
1965 if (HandleToLong(&hFind) == ERROR_FILE_NOT_FOUND) {
1968 if (hFind == INVALID_HANDLE_VALUE) {
1972 std::string fileName = FindFileData.cFileName;
1973 if (fileName !=
"." && fileName !=
"..") {
1974 files.push_back(fileName);
1976 }
while (FindNextFile(hFind, &FindFileData));
1978 std::sort(files.begin(), files.end());
1983 "Cannot read files of directory %s: not implemented on "
1984 "Universal Windows Platform",
1995 file.read((
char *)(&short_value),
sizeof(short_value));
1997#ifdef VISP_BIG_ENDIAN
2008 file.read((
char *)(&ushort_value),
sizeof(ushort_value));
2010#ifdef VISP_BIG_ENDIAN
2021 file.read((
char *)(&int_value),
sizeof(int_value));
2023#ifdef VISP_BIG_ENDIAN
2034 file.read((
char *)(&uint_value),
sizeof(uint_value));
2036#ifdef VISP_BIG_ENDIAN
2047 file.read((
char *)(&float_value),
sizeof(float_value));
2049#ifdef VISP_BIG_ENDIAN
2060 file.read((
char *)(&double_value),
sizeof(double_value));
2062#ifdef VISP_BIG_ENDIAN
2073#ifdef VISP_BIG_ENDIAN
2076 file.write((
char *)(&swap_short),
sizeof(swap_short));
2078 file.write((
char *)(&short_value),
sizeof(short_value));
2087#ifdef VISP_BIG_ENDIAN
2090 file.write((
char *)(&swap_ushort),
sizeof(swap_ushort));
2092 file.write((
char *)(&ushort_value),
sizeof(ushort_value));
2101#ifdef VISP_BIG_ENDIAN
2104 file.write((
char *)(&swap_int),
sizeof(swap_int));
2106 file.write((
char *)(&int_value),
sizeof(int_value));
2115#ifdef VISP_BIG_ENDIAN
2118 file.write((
char *)(&swap_int),
sizeof(swap_int));
2120 file.write((
char *)(&uint_value),
sizeof(uint_value));
2129#ifdef VISP_BIG_ENDIAN
2132 file.write((
char *)(&swap_float),
sizeof(swap_float));
2134 file.write((
char *)(&float_value),
sizeof(float_value));
2143#ifdef VISP_BIG_ENDIAN
2146 file.write((
char *)(&swap_double),
sizeof(swap_double));
2148 file.write((
char *)(&double_value),
sizeof(double_value));
2154 std::transform(input.begin(), input.end(), input.begin(), ::tolower);
2155 std::istringstream is(input);
2159 is >> (input.size() > 1 ? std::boolalpha : std::noboolalpha) >> b;
2168 return ltrim(rtrim(s));
unsigned int getCols() const
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int getRows() const
Class to define RGB colors available for display functionnalities.
static vpColor getColor(const unsigned int &i)
error that can be emited by ViSP classes.
@ notImplementedError
Not implemented.
Error that can be emited by the vpIoTools class and its derivates.
static Type minimum(const Type &a, const Type &b)
VISP_EXPORT float swapFloat(float f)
VISP_EXPORT uint32_t swap32bits(uint32_t val)
VISP_EXPORT double swapDouble(double d)
VISP_EXPORT uint16_t swap16bits(uint16_t val)