Path& Path::assign(const std::string& path) { #if defined(SYSTEM_SYSTEM_WINDOWS) parseWindows(path); #else parseUnix(path); #endif return *this; }
Path& Path::assign(const std::string& sPath) { #if defined(FX_WINDOWS) parseWindows(sPath); #else parseUnix(sPath); #endif return *this; }
Path& Path::assign(const std::string& path) { #if defined(POCO_OS_FAMILY_VMS) parseVMS(path); #elif defined(POCO_OS_FAMILY_WINDOWS) parseWindows(path); #else parseUnix(path); #endif return *this; }
void Path::parseGuess(const std::string& path) { bool hasBackslash = false; bool hasSlash = false; bool hasOpenBracket = false; bool hasClosBracket = false; bool isWindows = path.length() > 2 && path[1] == ':' && (path[2] == '/' || path[2] == '\\'); std::string::const_iterator end = path.end(); std::string::const_iterator semiIt = end; if (!isWindows) { for (std::string::const_iterator it = path.begin(); it != end; ++it) { switch (*it) { case '\\': hasBackslash = true; break; case '/': hasSlash = true; break; case '[': hasOpenBracket = true; case ']': hasClosBracket = hasOpenBracket; case ';': semiIt = it; break; } } } if (hasBackslash || isWindows) { parseWindows(path); } else if (hasSlash) { parseUnix(path); } else { bool isVMS = hasClosBracket; if (!isVMS && semiIt != end) { isVMS = true; ++semiIt; while (semiIt != end) { if (*semiIt < '0' || *semiIt > '9') { isVMS = false; break; } ++semiIt; } } if (isVMS) parseVMS(path); else parseUnix(path); } }
void Path::assign(const char* pathStr, UINT32 numChars, PathType type) { switch (type) { case PathType::Windows: parseWindows(pathStr, numChars); break; case PathType::Unix: parseUnix(pathStr, numChars); break; default: #if BS_PLATFORM == BS_PLATFORM_WIN32 parseWindows(pathStr, numChars); #elif BS_PLATFORM == BS_PLATFORM_OSX || BS_PLATFORM == BS_PLATFORM_LINUX parseUnix(pathStr, numChars); #else static_assert(false, "Unsupported platform for path."); #endif break; } }
Path& Path::assign(const std::string& sPath, Style style) { switch (style) { case PATH_UNIX: parseUnix(sPath); break; case PATH_WINDOWS: parseWindows(sPath); break; case PATH_NATIVE: assign(sPath); break; case PATH_GUESS: parseGuess(sPath); break; default: throw BadParameterException(); } return *this; }
Path& Path::assign(const std::string& path, Style style) { switch (style) { case PATH_UNIX: parseUnix(path); break; case PATH_WINDOWS: parseWindows(path); break; case PATH_VMS: parseVMS(path); break; case PATH_NATIVE: assign(path); break; case PATH_GUESS: parseGuess(path); break; default: break; } return *this; }
void Path::parseGuess(const std::string& sPath) { bool hasBackslash = false; bool hasSlash = false; // bool hasOpenBracket = false; // bool hasClosBracket = false; bool isWindows = sPath.length() > 2 && sPath[1] == ':' && (sPath[2] == '/' || sPath[2] == '\\'); std::string::const_iterator end = sPath.end(); std::string::const_iterator semiIt = end; if (!isWindows) { for (std::string::const_iterator it = sPath.begin(); it != end; ++it) { switch (*it) { case '\\': hasBackslash = true; break; case '/': hasSlash = true; break; // case '[': hasOpenBracket = true; // case ']': hasClosBracket = hasOpenBracket; case ';': semiIt = it; break; } } } if (hasBackslash || isWindows) { parseWindows(sPath); } else if (hasSlash) { parseUnix(sPath); } else { parseUnix(sPath); } }