Added to_lower() functions
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@861 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ea1a165a95
commit
1c4b41005c
|
@ -11,6 +11,7 @@
|
||||||
#ifndef _STORAGE_SUPPORT_H
|
#ifndef _STORAGE_SUPPORT_H
|
||||||
#define _STORAGE_SUPPORT_H
|
#define _STORAGE_SUPPORT_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
|
@ -38,6 +39,18 @@ status_t check_entry_name(const char *entry);
|
||||||
//! Checks whether a path name is a valid path name.
|
//! Checks whether a path name is a valid path name.
|
||||||
status_t check_path_name(const char *path);
|
status_t check_path_name(const char *path);
|
||||||
|
|
||||||
|
//! Returns a copy of \c str in which all alphabetic characters are lowercase.
|
||||||
|
std::string to_lower(const char *str);
|
||||||
|
|
||||||
|
//! Places a copy of \c str in \c result in which all alphabetic characters are lowercase.
|
||||||
|
void to_lower(const char *str, std::string &result);
|
||||||
|
|
||||||
|
//! Copies \c str into \c result, converting any uppercase alphabetics to lowercase.
|
||||||
|
void to_lower(const char *str, char *result);
|
||||||
|
|
||||||
|
//! Converts \c str to lowercase.
|
||||||
|
void to_lower(char *str);
|
||||||
|
|
||||||
}; // namespace Storage
|
}; // namespace Storage
|
||||||
}; // namespace BPrivate
|
}; // namespace BPrivate
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <StorageDefs.h>
|
#include <StorageDefs.h>
|
||||||
|
@ -315,6 +316,49 @@ check_path_name(const char *path)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns "(null)" if you're a bonehead and pass in a \c NULL pointer.
|
||||||
|
*/
|
||||||
|
std::string
|
||||||
|
to_lower(const char *str)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
to_lower(str, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Returns "(null)" if you're a bonehead and pass in a \c NULL pointer.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
to_lower(const char *str, std::string &result)
|
||||||
|
{
|
||||||
|
if (str) {
|
||||||
|
result = "";
|
||||||
|
for (int i = 0; i < strlen(str); i++)
|
||||||
|
result += tolower(str[i]);
|
||||||
|
} else
|
||||||
|
result = "(null)";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \c str and \c result may point to the same string. \c result is
|
||||||
|
assumed to be as long as or longer than \c str.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
to_lower(const char *str, char *result)
|
||||||
|
{
|
||||||
|
if (str && result) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < strlen(str); i++)
|
||||||
|
result[i] = tolower(str[i]);
|
||||||
|
result[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
to_lower(char *str)
|
||||||
|
{
|
||||||
|
to_lower(str, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // namespace Storage
|
}; // namespace Storage
|
||||||
}; // namespace BPrivate
|
}; // namespace BPrivate
|
||||||
|
|
Loading…
Reference in New Issue