65 #include <sys/types.h>
66 #include <visp3/core/vpDebug.h>
67 #include <visp3/core/vpEndian.h>
68 #include <visp3/core/vpIoException.h>
69 #include <visp3/core/vpIoTools.h>
70 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
85 #if defined(__APPLE__) && defined(__MACH__)
86 #include <TargetConditionals.h>
91 #define PATH_MAX _MAX_PATH
107 #if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
108 #if (TARGET_OS_IOS == 0) && !defined(__ANDROID__)
109 void replaceAll(std::string &str,
const std::string &search,
const std::string &replace)
111 size_t start_pos = 0;
112 while ((start_pos = str.find(search, start_pos)) != std::string::npos) {
113 str.replace(start_pos, search.length(), replace);
114 start_pos += replace.length();
121 std::string <rim(std::string &s)
123 #if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
124 s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](
int c) { return !std::isspace(c); }));
126 s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
131 std::string &rtrim(std::string &s)
133 #if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
134 s.erase(std::find_if(s.rbegin(), s.rend(), [](
int c) { return !std::isspace(c); }).base(), s.end());
136 s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
147 static std::string build_info =
148 #include "version_string.inc"
206 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
207 std::string username;
209 return "/tmp/" + username;
210 #elif defined(_WIN32) && !defined(WINRT)
213 TCHAR lpTempPathBuffer[MAX_PATH];
214 DWORD dwRetVal = GetTempPath(MAX_PATH , lpTempPathBuffer );
215 if (dwRetVal > MAX_PATH || (dwRetVal == 0)) {
218 std::string temp_path(lpTempPathBuffer);
219 if (!temp_path.empty()) {
220 if (temp_path.back() ==
'\\') {
221 temp_path.resize(temp_path.size() - 1);
224 temp_path =
"C:\temp";
281 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
283 char *_username =
::getenv(
"LOGNAME");
285 username =
"unknown";
287 username = _username;
289 #elif defined(_WIN32)
290 #if (!defined(WINRT))
291 unsigned int info_buffer_size = 1024;
292 TCHAR *infoBuf =
new TCHAR[info_buffer_size];
293 DWORD bufCharCount = (DWORD)info_buffer_size;
295 if (!GetUserName(infoBuf, &bufCharCount)) {
296 username =
"unknown";
303 username =
"unknown";
306 username =
"unknown";
326 std::string username;
363 #if defined(_WIN32) && defined(WINRT)
365 "implemented on Universal Windows Platform"));
369 char *_value =
::getenv(env.c_str());
388 void vpIoTools::getVersion(
const std::string &version,
unsigned int &major,
unsigned int &minor,
unsigned int &patch)
390 if (version.size() == 0) {
395 size_t major_pos = version.find(
'.');
396 std::string major_str = version.substr(0, major_pos);
397 major =
static_cast<unsigned>(atoi(major_str.c_str()));
399 if (major_pos != std::string::npos) {
400 size_t minor_pos = version.find(
'.', major_pos + 1);
401 std::string minor_str = version.substr(major_pos + 1, (minor_pos - (major_pos + 1)));
402 minor =
static_cast<unsigned>(atoi(minor_str.c_str()));
404 if (minor_pos != std::string::npos) {
405 std::string patch_str = version.substr(minor_pos + 1);
406 patch =
static_cast<unsigned>(atoi(patch_str.c_str()));
430 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
432 #elif defined(_WIN32) && defined(__MINGW32__)
434 #elif defined(_WIN32)
438 if (dirname.empty()) {
442 std::string _dirname =
path(dirname);
444 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
445 if (stat(_dirname.c_str(), &stbuf) != 0)
446 #elif defined(_WIN32) && defined(__MINGW32__)
451 _dirname = _dirname.substr(0, _dirname.size() - 1);
452 if (stat(_dirname.c_str(), &stbuf) != 0)
453 #elif defined(_WIN32)
454 if (_stat(_dirname.c_str(), &stbuf) != 0)
459 #if defined(_WIN32) || (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
460 if ((stbuf.st_mode & S_IFDIR) == 0)
465 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
466 if ((stbuf.st_mode & S_IWUSR) == 0)
467 #elif defined(_WIN32)
468 if ((stbuf.st_mode & S_IWRITE) == 0)
490 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
493 std::string _filename =
path(fifofilename);
494 if (stat(_filename.c_str(), &stbuf) != 0) {
497 if ((stbuf.st_mode & S_IFIFO) == 0) {
500 if ((stbuf.st_mode & S_IRUSR) == 0)
506 #elif defined(_WIN32)
512 #ifndef DOXYGEN_SHOULD_SKIP_THIS
515 int vpIoTools::mkdir_p(
const char *path,
int mode)
518 const size_t len = strlen(
path);
519 char _path[PATH_MAX];
522 std::fill(_path, _path + PATH_MAX, 0);
525 if (len >
sizeof(_path) - 1) {
526 errno = ENAMETOOLONG;
533 for (
char *p = _path + 1; *p; p++) {
538 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
539 if (mkdir(_path,
static_cast<mode_t
>(mode)) != 0)
540 #elif defined(_WIN32)
552 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
553 if (mkdir(_path,
static_cast<mode_t
>(mode)) != 0)
554 #elif defined(_WIN32)
555 if (_mkdir(_path) != 0)
580 #if ((!defined(__unix__) && !defined(__unix) && (!defined(__APPLE__) || !defined(__MACH__)))) && !defined(_WIN32)
581 std::cerr <<
"Unsupported platform for vpIoTools::makeDirectory()!" << std::endl;
585 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
587 #elif defined(_WIN32) && defined(__MINGW32__)
589 #elif defined(_WIN32)
593 if (dirname.empty()) {
597 std::string _dirname =
path(dirname);
599 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
600 if (stat(_dirname.c_str(), &stbuf) != 0)
601 #elif defined(_WIN32) && defined(__MINGW32__)
602 if (stat(_dirname.c_str(), &stbuf) != 0)
603 #elif defined(_WIN32)
604 if (_stat(_dirname.c_str(), &stbuf) != 0)
607 if (vpIoTools::mkdir_p(_dirname.c_str(), 0755) != 0) {
631 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
636 "Unable to create fifo file. '%s' is an existing directory.", fifoname.c_str()));
649 else if (mkfifo(fifoname.c_str(), 0666) < 0) {
652 #elif defined(_WIN32)
658 #if defined(_WIN32) && !defined(WINRT)
659 std::string getUuid()
662 if (UuidCreate(&uuid) != RPC_S_OK) {
667 if (UuidToString(&uuid, &stringUuid) != RPC_S_OK) {
671 return reinterpret_cast<char *
>(stringUuid);
733 #if defined(WINRT) || !defined(_WIN32) && !(defined(__unix__) || defined(__unix) || \
734 (defined(__APPLE__) && defined(__MACH__)))
738 std::string dirname_cpy = std::string(dirname);
739 std::string correctEnding =
"XXXXXX";
743 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
745 if (dirname_cpy.rfind(correctEnding) == std::string::npos) {
746 if (dirname_cpy.at(dirname_cpy.length() - 1) !=
'/') {
747 dirname_cpy = dirname_cpy +
"/";
755 dirname_cpy = dirname_cpy +
"XXXXXX";
758 #elif defined(_WIN32) && !defined(WINRT)
760 dirname_cpy = dirname_cpy.substr(0, dirname_cpy.rfind(correctEnding));
762 dirname_cpy = dirname_cpy + getUuid();
767 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
768 if (dirname_cpy.at(dirname_cpy.length() - 1) !=
'/') {
769 dirname_cpy = dirname_cpy +
"/";
771 dirname_cpy = dirname_cpy +
"XXXXXX";
772 #elif defined(_WIN32) && !defined(WINRT)
777 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
778 char *dirname_char =
new char[dirname_cpy.length() + 1];
779 strcpy(dirname_char, dirname_cpy.c_str());
781 char *computedDirname = mkdtemp(dirname_char);
783 if (!computedDirname) {
784 delete[] dirname_char;
788 std::string res(computedDirname);
789 delete[] dirname_char;
791 #elif defined(_WIN32) && !defined(WINRT)
809 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
811 #elif defined(_WIN32)
815 if (filename.empty()) {
819 std::string _filename =
path(filename);
820 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
821 if (stat(_filename.c_str(), &stbuf) != 0)
822 #elif defined(_WIN32)
823 if (_stat(_filename.c_str(), &stbuf) != 0)
828 if ((stbuf.st_mode & S_IFREG) == 0) {
831 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
832 if ((stbuf.st_mode & S_IRUSR) == 0)
833 #elif defined(_WIN32)
834 if ((stbuf.st_mode & S_IREAD) == 0)
854 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
855 #if TARGET_OS_IOS == 0
857 std::stringstream cmd;
862 int ret = system(cmd.str().c_str());
871 #elif defined(_WIN32)
872 #if (!defined(WINRT))
873 std::stringstream cmd;
878 int ret = system(cmd.str().c_str());
885 src.c_str(), dst.c_str()));
890 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
891 #if TARGET_OS_IOS == 0
893 std::stringstream cmd;
898 int ret = system(cmd.str().c_str());
907 #elif defined(_WIN32)
908 #if (!defined(WINRT))
909 std::stringstream cmd;
914 int ret = system(cmd.str().c_str());
921 src.c_str(), dst.c_str()));
925 std::cout <<
"Cannot copy: " << src <<
" in " << dst << std::endl;
944 #
if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
949 if (::
remove(file_or_dir.c_str()) != 0)
955 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
956 #if TARGET_OS_IOS == 0
958 std::stringstream cmd;
962 int ret = system(cmd.str().c_str());
969 file_or_dir.c_str()));
971 #elif defined(_WIN32)
972 #if (!defined(WINRT))
973 std::stringstream cmd;
974 cmd <<
"rmdir /S /Q ";
977 int ret = system(cmd.str().c_str());
984 file_or_dir.c_str()));
988 std::cout <<
"Cannot remove: " << file_or_dir << std::endl;
1004 if (::
rename(oldfilename.c_str(), newfilename.c_str()) != 0)
1022 std::string
path(pathname);
1025 for (
unsigned int i = 0; i <
path.length(); i++)
1028 #elif defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
1029 for (
unsigned int i = 0; i <
path.length(); i++)
1030 if (
path[i] ==
'\\')
1032 #if TARGET_OS_IOS == 0
1037 wordexp_t exp_result;
1040 replaceAll(
path,
"'",
"'\\''");
1042 wordexp(std::string(
"'" +
path +
"'").c_str(), &exp_result, 0);
1043 path = exp_result.we_wordc == 1 ? exp_result.we_wordv[0] :
"";
1044 wordfree(&exp_result);
1065 std::ifstream confContent(
configFile.c_str(), std::ios::in);
1067 if (confContent.is_open()) {
1068 std::string line, var, val;
1069 long unsigned int k;
1071 std::string stop[3] = {
" ",
"\t",
"#"};
1072 while (std::getline(confContent, line)) {
1073 if ((line.compare(0, 1,
"#") != 0) && (line.size() > 2)) {
1076 k =
static_cast<unsigned long>(line.find(
" "));
1077 var = line.substr(0, k);
1080 for (
unsigned i = 0; i < 3; ++i)
1082 static_cast<int>(line.find(stop[i],
static_cast<size_t>(k) +
static_cast<size_t>(1))));
1084 c =
static_cast<int>(line.size());
1085 long unsigned int c_ =
static_cast<long unsigned int>(c);
1086 val = line.substr(
static_cast<size_t>(k) +
static_cast<size_t>(1),
1087 static_cast<size_t>(c_) -
static_cast<size_t>(k) -
static_cast<size_t>(1));
1094 confContent.close();
1112 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1115 value =
static_cast<float>(M_PI);
1117 value =
static_cast<float>(M_PI / 2.0);
1119 value =
static_cast<float>(-M_PI / 2.0);
1121 value =
static_cast<float>(atof(
configValues[k].c_str()));
1126 std::cout << var <<
" not found in config file" << std::endl;
1140 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1154 std::cout << var <<
" not found in config file" << std::endl;
1169 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1176 std::cout << var <<
" not found in config file" << std::endl;
1192 value =
static_cast<unsigned int>(v);
1239 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1246 std::cout << var <<
" not found in config file" << std::endl;
1264 const unsigned int &nRows)
1268 for (
unsigned int k = 0; k <
configVars.size() && found ==
false; ++k) {
1272 if (nCols != 0 && nRows != 0)
1273 value.
resize(nRows, nCols);
1274 size_t ind = 0, ind2;
1275 for (
unsigned int i = 0; i < value.
getRows(); ++i)
1276 for (
unsigned int j = 0; j < value.
getCols(); ++j) {
1279 if (nb.compare(
"PI") == 0)
1281 else if (nb.compare(
"PI/2") == 0)
1282 value[i][j] = M_PI / 2;
1283 else if (nb.compare(
"-PI/2") == 0)
1284 value[i][j] = -M_PI / 2;
1286 value[i][j] = atof(nb.c_str());
1292 std::cout << var <<
" not found in config file" << std::endl;
1310 else if (strFalse !=
"")
1325 if (std::fabs(val) < std::numeric_limits<double>::epsilon()) {
1326 std::stringstream valS;
1329 baseName +=
"_" + strTrue + valS.str();
1384 std::string data_path;
1385 std::string file_to_test(
"mbt/cube.cao");
1386 std::string filename;
1390 filename = data_path +
"/" + file_to_test;
1394 filename = data_path +
"/" + file_to_test;
1398 filename = data_path +
"/" + file_to_test;
1403 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
1405 data_path =
"/usr/share/visp-images-data/ViSP-images";
1406 filename = data_path +
"/" + file_to_test;
1409 data_path =
"/usr/share/visp-images-data/visp-images";
1410 filename = data_path +
"/" + file_to_test;
1454 std::string sep =
"\\";
1455 std::string altsep =
"/";
1456 std::string extsep =
".";
1459 std::string sep =
"/";
1460 std::string altsep =
"";
1461 std::string extsep =
".";
1494 int sepIndex =
static_cast<int>(pathname.rfind(sep));
1495 if (!altsep.empty()) {
1496 int altsepIndex =
static_cast<int>(pathname.rfind(altsep));
1497 sepIndex = ((std::max))(sepIndex, altsepIndex);
1500 size_t dotIndex = pathname.rfind(extsep);
1501 if (dotIndex != std::string::npos) {
1503 size_t npos = std::string::npos;
1504 if ((sepIndex !=
static_cast<int>(npos) &&
static_cast<int>(dotIndex) > sepIndex) ||
1505 sepIndex ==
static_cast<int>(npos)) {
1506 if (sepIndex ==
static_cast<int>(npos)) {
1509 size_t filenameIndex =
static_cast<size_t>(sepIndex) +
static_cast<size_t>(1);
1511 while (filenameIndex < dotIndex) {
1512 if (pathname.compare(filenameIndex, 1, extsep) != 0) {
1513 return pathname.substr(dotIndex);
1530 if (pathname.size() > 0) {
1534 if (index != std::string::npos) {
1535 return convertedPathname.substr(index + 1);
1538 return convertedPathname;
1553 size_t found = name.find_last_of(
".");
1554 std::string name_we = name.substr(0, found);
1593 size_t indexBegin = format.find_last_of(
'%');
1594 size_t indexEnd = format.find_first_of(
'd', indexBegin);
1595 size_t suffixLength = format.length() - indexEnd - 1;
1597 if (filename.length() <= suffixLength + indexBegin) {
1600 size_t indexLength = filename.length() - suffixLength - indexBegin;
1601 std::string indexSubstr = filename.substr(indexBegin, indexLength);
1602 std::istringstream ss(indexSubstr);
1605 if (ss.fail() || index < 0 || !ss.eof()) {
1610 char nameByFormat[FILENAME_MAX];
1611 snprintf(nameByFormat, FILENAME_MAX, format.c_str(), index);
1612 if (std::string(nameByFormat) != filename) {
1635 if (pathname.size() > 0) {
1639 if (index != std::string::npos) {
1640 return convertedPathname.substr(0, index);
1660 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
1661 std::string real_path_str = pathname;
1662 char *real_path = realpath(pathname.c_str(), NULL);
1665 real_path_str = real_path;
1668 return real_path_str;
1669 #elif defined(_WIN32)
1670 #if (!defined(WINRT))
1671 std::string real_path_str = pathname;
1673 TCHAR buffer[4096] = TEXT(
"");
1675 retval = GetFullPathName(pathname.c_str(), 4096, buffer, 0);
1677 real_path_str = buffer;
1679 return real_path_str;
1682 "Cannot get absolute path of %s: not implemented on "
1683 "Universal Windows Platform",
1701 if (child.size() == 0 && parent.size() == 0) {
1705 if (child.size() == 0) {
1709 if (parent.size() == 0) {
1716 std::stringstream ss;
1718 std::string stringSeparator;
1719 ss >> stringSeparator;
1721 std::string lastConvertedParentChar = convertedParent.substr(convertedParent.size() - 1);
1722 std::string firstConvertedChildChar = convertedChild.substr(0, 1);
1724 if (lastConvertedParentChar == stringSeparator) {
1725 convertedParent = convertedParent.substr(0, convertedParent.size() - 1);
1728 if (firstConvertedChildChar == stringSeparator) {
1729 convertedChild = convertedChild.substr(1);
1754 return path.size() > 0 && (
path.substr(0, 1) ==
"/" ||
path.substr(0, 1) ==
"\\");
1774 return (path1_normalize == path2_normalize);
1837 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
1838 return std::pair<std::string, std::string>(
"", pathname);
1840 const std::string sep =
"\\";
1841 const std::string sepsep =
"\\\\";
1842 const std::string altsep =
"/";
1844 if (pathname.size() > 1) {
1845 std::string normPathname = pathname;
1846 std::replace(normPathname.begin(), normPathname.end(), *altsep.c_str(), *sep.c_str());
1848 if (normPathname.substr(0, 2) == sepsep && normPathname.substr(2, 1) != sep) {
1853 size_t index = normPathname.find(sep, 2);
1854 if (index == std::string::npos) {
1855 return std::pair<std::string, std::string>(
"", pathname);
1858 size_t index2 = normPathname.find(sep, index + 1);
1861 if (index2 == index + 1) {
1862 return std::pair<std::string, std::string>(
"", pathname);
1865 if (index2 == std::string::npos) {
1866 index2 = pathname.size();
1869 return std::pair<std::string, std::string>(pathname.substr(0, index2), pathname.substr(index2));
1872 if (normPathname[1] ==
':') {
1873 return std::pair<std::string, std::string>(pathname.substr(0, 2), pathname.substr(2));
1877 return std::pair<std::string, std::string>(
"", pathname);
1931 size_t startIndex = 0;
1933 std::string chainToSplit = chain;
1934 std::vector<std::string> subChain;
1935 size_t sepIndex = chainToSplit.find(sep);
1937 while (sepIndex != std::string::npos) {
1938 std::string sub = chainToSplit.substr(startIndex, sepIndex);
1940 subChain.push_back(sub);
1941 chainToSplit = chainToSplit.substr(sepIndex + 1, chain.size() - 1);
1943 sepIndex = chainToSplit.find(sep);
1945 if (!chainToSplit.empty())
1946 subChain.push_back(chainToSplit);
1964 std::string dirName =
path(pathname);
1966 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
1968 std::vector<std::string> files;
1969 struct dirent **list = NULL;
1970 int filesCount = scandir(dirName.c_str(), &list, NULL, NULL);
1971 if (filesCount == -1) {
1974 for (
int i = 0; i < filesCount; i++) {
1975 std::string fileName = list[i]->d_name;
1976 if (fileName !=
"." && fileName !=
"..") {
1977 files.push_back(fileName);
1982 std::sort(files.begin(), files.end());
1985 #elif defined(_WIN32)
1986 #if (!defined(WINRT))
1988 std::vector<std::string> files;
1989 std::string fileMask = dirName;
1990 fileMask.append(
"\\*");
1991 WIN32_FIND_DATA FindFileData;
1992 HANDLE hFind = FindFirstFile(fileMask.c_str(), &FindFileData);
1994 if (HandleToLong(&hFind) == ERROR_FILE_NOT_FOUND) {
1997 if (hFind == INVALID_HANDLE_VALUE) {
2001 std::string fileName = FindFileData.cFileName;
2002 if (fileName !=
"." && fileName !=
"..") {
2003 files.push_back(fileName);
2005 }
while (FindNextFile(hFind, &FindFileData));
2007 std::sort(files.begin(), files.end());
2012 "Cannot read files of directory %s: not implemented on "
2013 "Universal Windows Platform",
2024 file.read((
char *)(&short_value),
sizeof(short_value));
2026 #ifdef VISP_BIG_ENDIAN
2037 file.read((
char *)(&ushort_value),
sizeof(ushort_value));
2039 #ifdef VISP_BIG_ENDIAN
2050 file.read((
char *)(&int_value),
sizeof(int_value));
2052 #ifdef VISP_BIG_ENDIAN
2063 file.read((
char *)(&uint_value),
sizeof(uint_value));
2065 #ifdef VISP_BIG_ENDIAN
2076 file.read((
char *)(&float_value),
sizeof(float_value));
2078 #ifdef VISP_BIG_ENDIAN
2089 file.read((
char *)(&double_value),
sizeof(double_value));
2091 #ifdef VISP_BIG_ENDIAN
2102 #ifdef VISP_BIG_ENDIAN
2105 file.write((
char *)(&swap_short),
sizeof(swap_short));
2107 file.write((
char *)(&short_value),
sizeof(short_value));
2116 #ifdef VISP_BIG_ENDIAN
2119 file.write((
char *)(&swap_ushort),
sizeof(swap_ushort));
2121 file.write((
char *)(&ushort_value),
sizeof(ushort_value));
2130 #ifdef VISP_BIG_ENDIAN
2133 file.write((
char *)(&swap_int),
sizeof(swap_int));
2135 file.write((
char *)(&int_value),
sizeof(int_value));
2144 #ifdef VISP_BIG_ENDIAN
2147 file.write((
char *)(&swap_int),
sizeof(swap_int));
2149 file.write((
char *)(&uint_value),
sizeof(uint_value));
2158 #ifdef VISP_BIG_ENDIAN
2161 file.write((
char *)(&swap_float),
sizeof(swap_float));
2163 file.write((
char *)(&float_value),
sizeof(float_value));
2172 #ifdef VISP_BIG_ENDIAN
2175 file.write((
char *)(&swap_double),
sizeof(swap_double));
2177 file.write((
char *)(&double_value),
sizeof(double_value));
2183 std::transform(input.begin(), input.end(), input.begin(), ::tolower);
2184 std::istringstream is(input);
2188 is >> (input.size() > 1 ? std::boolalpha : std::noboolalpha) >> b;
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)