Cleaned-up the std namespace support

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3475 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
haydentech
2003-06-11 14:34:51 +00:00
parent 2e9a7f0c99
commit 98833b15bf
12 changed files with 77 additions and 55 deletions
+4 -2
View File
@@ -22,6 +22,8 @@
using namespace OpenBeOS; using namespace OpenBeOS;
#endif #endif
using namespace std;
// SYMLINK_MAX is needed by B_SYMLINK_MAX // SYMLINK_MAX is needed by B_SYMLINK_MAX
// I don't know, why it isn't defined. // I don't know, why it isn't defined.
#ifndef SYMLINK_MAX #ifndef SYMLINK_MAX
@@ -114,7 +116,7 @@ status_t entry_ref::set_name(const char *name)
if (name == NULL) { if (name == NULL) {
this->name = NULL; this->name = NULL;
} else { } else {
this->name = new(std::nothrow) char[strlen(name)+1]; this->name = new(nothrow) char[strlen(name)+1];
if (this->name == NULL) if (this->name == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
strcpy(this->name, name); strcpy(this->name, name);
@@ -1047,7 +1049,7 @@ BEntry::set_name(const char *name)
delete [] fName; delete [] fName;
} }
fName = new(std::nothrow) char[strlen(name)+1]; fName = new(nothrow) char[strlen(name)+1];
if (fName == NULL) if (fName == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
+2 -1
View File
@@ -14,7 +14,7 @@
#include <sniffer/Parser.h> #include <sniffer/Parser.h>
#include <ctype.h> // For tolower() #include <ctype.h> // For tolower()
#include <new.h> // For new(nothrow) #include <new> // For new(nothrow)
#include <stdio.h> // For printf() #include <stdio.h> // For printf()
#include <string.h> // For strncpy() #include <string.h> // For strncpy()
#include <RegistrarDefs.h> #include <RegistrarDefs.h>
@@ -29,6 +29,7 @@ enum {
}; };
using namespace BPrivate::Storage::Mime; using namespace BPrivate::Storage::Mime;
using namespace std;
const char *B_PEF_APP_MIME_TYPE = "application/x-be-executable"; const char *B_PEF_APP_MIME_TYPE = "application/x-be-executable";
const char *B_PE_APP_MIME_TYPE = "application/x-vnd.be-peexecutable"; const char *B_PE_APP_MIME_TYPE = "application/x-vnd.be-peexecutable";
+2
View File
@@ -19,6 +19,8 @@
#include <fs_attr.h> #include <fs_attr.h>
using namespace std;
// attribute names // attribute names
#define NI_BEOS "BEOS" #define NI_BEOS "BEOS"
static const char *kNITypeAttribute = NI_BEOS ":TYPE"; static const char *kNITypeAttribute = NI_BEOS ":TYPE";
+3 -1
View File
@@ -17,6 +17,8 @@
#include "kernel_interface.h" #include "kernel_interface.h"
#include "storage_support.h" #include "storage_support.h"
using namespace std;
#ifdef USE_OPENBEOS_NAMESPACE #ifdef USE_OPENBEOS_NAMESPACE
using namespace OpenBeOS; using namespace OpenBeOS;
#endif #endif
@@ -600,7 +602,7 @@ BPath::set_path(const char *path)
const char *oldPath = fName; const char *oldPath = fName;
// set the new path // set the new path
if (path) { if (path) {
fName = new(std::nothrow) char[strlen(path) + 1]; fName = new(nothrow) char[strlen(path) + 1];
if (fName) if (fName)
strcpy(fName, path); strcpy(fName, path);
else else
+15 -14
View File
@@ -20,6 +20,7 @@
#include "QueryPredicate.h" #include "QueryPredicate.h"
using namespace BPrivate::Storage; using namespace BPrivate::Storage;
using namespace std;
enum { enum {
@@ -95,7 +96,7 @@ BQuery::Clear()
status_t status_t
BQuery::PushAttr(const char *attrName) BQuery::PushAttr(const char *attrName)
{ {
return _PushNode(new(std::nothrow) AttributeNode(attrName), true); return _PushNode(new(nothrow) AttributeNode(attrName), true);
} }
// PushOp // PushOp
@@ -129,13 +130,13 @@ BQuery::PushOp(query_op op)
case B_ENDS_WITH: case B_ENDS_WITH:
case B_AND: case B_AND:
case B_OR: case B_OR:
error = _PushNode(new(std::nothrow) BinaryOpNode(op), true); error = _PushNode(new(nothrow) BinaryOpNode(op), true);
break; break;
case B_NOT: case B_NOT:
error = _PushNode(new(std::nothrow) UnaryOpNode(op), true); error = _PushNode(new(nothrow) UnaryOpNode(op), true);
break; break;
default: default:
error = _PushNode(new(std::nothrow) SpecialOpNode(op), true); error = _PushNode(new(nothrow) SpecialOpNode(op), true);
break; break;
} }
return error; return error;
@@ -159,7 +160,7 @@ BQuery::PushOp(query_op op)
status_t status_t
BQuery::PushUInt32(uint32 value) BQuery::PushUInt32(uint32 value)
{ {
return _PushNode(new(std::nothrow) UInt32ValueNode(value), true); return _PushNode(new(nothrow) UInt32ValueNode(value), true);
} }
// PushInt32 // PushInt32
@@ -180,7 +181,7 @@ BQuery::PushUInt32(uint32 value)
status_t status_t
BQuery::PushInt32(int32 value) BQuery::PushInt32(int32 value)
{ {
return _PushNode(new(std::nothrow) Int32ValueNode(value), true); return _PushNode(new(nothrow) Int32ValueNode(value), true);
} }
// PushUInt64 // PushUInt64
@@ -201,7 +202,7 @@ BQuery::PushInt32(int32 value)
status_t status_t
BQuery::PushUInt64(uint64 value) BQuery::PushUInt64(uint64 value)
{ {
return _PushNode(new(std::nothrow) UInt64ValueNode(value), true); return _PushNode(new(nothrow) UInt64ValueNode(value), true);
} }
// PushInt64 // PushInt64
@@ -222,7 +223,7 @@ BQuery::PushUInt64(uint64 value)
status_t status_t
BQuery::PushInt64(int64 value) BQuery::PushInt64(int64 value)
{ {
return _PushNode(new(std::nothrow) Int64ValueNode(value), true); return _PushNode(new(nothrow) Int64ValueNode(value), true);
} }
// PushFloat // PushFloat
@@ -243,7 +244,7 @@ BQuery::PushInt64(int64 value)
status_t status_t
BQuery::PushFloat(float value) BQuery::PushFloat(float value)
{ {
return _PushNode(new(std::nothrow) FloatValueNode(value), true); return _PushNode(new(nothrow) FloatValueNode(value), true);
} }
// PushDouble // PushDouble
@@ -264,7 +265,7 @@ BQuery::PushFloat(float value)
status_t status_t
BQuery::PushDouble(double value) BQuery::PushDouble(double value)
{ {
return _PushNode(new(std::nothrow) DoubleValueNode(value), true); return _PushNode(new(nothrow) DoubleValueNode(value), true);
} }
// PushString // PushString
@@ -287,7 +288,7 @@ BQuery::PushDouble(double value)
status_t status_t
BQuery::PushString(const char *value, bool caseInsensitive) BQuery::PushString(const char *value, bool caseInsensitive)
{ {
return _PushNode(new(std::nothrow) StringNode(value, caseInsensitive), true); return _PushNode(new(nothrow) StringNode(value, caseInsensitive), true);
} }
// PushDate // PushDate
@@ -319,7 +320,7 @@ BQuery::PushDate(const char *date)
} }
} }
if (error == B_OK) if (error == B_OK)
error = _PushNode(new(std::nothrow) DateNode(date), true); error = _PushNode(new(nothrow) DateNode(date), true);
return error; return error;
} }
@@ -677,7 +678,7 @@ BQuery::_PushNode(QueryNode *node, bool deleteOnError)
error = B_NOT_ALLOWED; error = B_NOT_ALLOWED;
// allocate the stack, if necessary // allocate the stack, if necessary
if (error == B_OK && !fStack) { if (error == B_OK && !fStack) {
fStack = new(std::nothrow) QueryStack; fStack = new(nothrow) QueryStack;
if (!fStack) if (!fStack)
error = B_NO_MEMORY; error = B_NO_MEMORY;
} }
@@ -705,7 +706,7 @@ BQuery::_SetPredicate(const char *expression)
fPredicate = NULL; fPredicate = NULL;
// set the new one // set the new one
if (expression) { if (expression) {
fPredicate = new(std::nothrow) char[strlen(expression) + 1]; fPredicate = new(nothrow) char[strlen(expression) + 1];
if (fPredicate) if (fPredicate)
strcpy(fPredicate, expression); strcpy(fPredicate, expression);
else else
+8 -6
View File
@@ -7,9 +7,9 @@
ResourceFile implementation. ResourceFile implementation.
*/ */
#include "ResourceFile.h" #include <ResourceFile.h>
#include <algobase.h> #include <algorithm>
#include <new> #include <new>
#include <stdio.h> #include <stdio.h>
@@ -21,6 +21,8 @@
#include "ResourcesDefs.h" #include "ResourcesDefs.h"
//#include "Warnings.h" //#include "Warnings.h"
using namespace std;
namespace BPrivate { namespace BPrivate {
namespace Storage { namespace Storage {
@@ -822,7 +824,7 @@ ResourceFile::_ReadIndexEntry(resource_parse_info &parseInfo, int32 index,
} }
// add the entry // add the entry
if (result) { if (result) {
ResourceItem *item = new(std::nothrow) ResourceItem; ResourceItem *item = new(nothrow) ResourceItem;
if (!item) if (!item)
throw Exception(B_NO_MEMORY); throw Exception(B_NO_MEMORY);
item->SetLocation(offset, size); item->SetLocation(offset, size);
@@ -841,7 +843,7 @@ ResourceFile::_ReadInfoTable(resource_parse_info &parseInfo)
int32 &resourceCount = parseInfo.resource_count; int32 &resourceCount = parseInfo.resource_count;
// read the info table // read the info table
// alloc memory for the table // alloc memory for the table
char *tableData = new(std::nothrow) char[parseInfo.info_table_size]; char *tableData = new(nothrow) char[parseInfo.info_table_size];
if (!tableData) if (!tableData)
throw Exception(B_NO_MEMORY); throw Exception(B_NO_MEMORY);
int32 dataSize = parseInfo.info_table_size; int32 dataSize = parseInfo.info_table_size;
@@ -849,7 +851,7 @@ ResourceFile::_ReadInfoTable(resource_parse_info &parseInfo)
read_exactly(fFile, parseInfo.info_table_offset, tableData, dataSize, read_exactly(fFile, parseInfo.info_table_offset, tableData, dataSize,
"Failed to read resource info table."); "Failed to read resource info table.");
// //
bool *readIndices = new(std::nothrow) bool[resourceCount + 1]; bool *readIndices = new(nothrow) bool[resourceCount + 1];
// + 1 => always > 0 // + 1 => always > 0
if (!readIndices) if (!readIndices)
throw Exception(B_NO_MEMORY); throw Exception(B_NO_MEMORY);
@@ -1074,7 +1076,7 @@ ResourceFile::_WriteResources(ResourcesContainer &container)
// write... // write...
// set the file size // set the file size
fFile.SetSize(size); fFile.SetSize(size);
buffer = new(std::nothrow) char[bufferSize]; buffer = new(nothrow) char[bufferSize];
if (!buffer) if (!buffer)
throw Exception(B_NO_MEMORY); throw Exception(B_NO_MEMORY);
void *data = buffer; void *data = buffer;
+3
View File
@@ -19,6 +19,9 @@
#include "kernel_interface.h" #include "kernel_interface.h"
using namespace std;
// constructor // constructor
/*! \brief Creates an object initialized to the application's string resources. /*! \brief Creates an object initialized to the application's string resources.
*/ */
+7 -6
View File
@@ -25,6 +25,7 @@
#include "ResourcesContainer.h" #include "ResourcesContainer.h"
using namespace BPrivate::Storage; using namespace BPrivate::Storage;
using namespace std;
enum { enum {
NOT_IMPLEMENTED = B_ERROR, NOT_IMPLEMENTED = B_ERROR,
@@ -39,7 +40,7 @@ BResources::BResources()
fResourceFile(NULL), fResourceFile(NULL),
fReadOnly(false) fReadOnly(false)
{ {
fContainer = new(std::nothrow) ResourcesContainer; fContainer = new(nothrow) ResourcesContainer;
} }
// constructor // constructor
@@ -61,7 +62,7 @@ BResources::BResources(const BFile *file, bool clobber)
fResourceFile(NULL), fResourceFile(NULL),
fReadOnly(false) fReadOnly(false)
{ {
fContainer = new(std::nothrow) ResourcesContainer; fContainer = new(nothrow) ResourcesContainer;
SetTo(file, clobber); SetTo(file, clobber);
} }
@@ -109,7 +110,7 @@ BResources::SetTo(const BFile *file, bool clobber)
} }
if (error == B_OK) { if (error == B_OK) {
fReadOnly = !fFile.IsWritable(); fReadOnly = !fFile.IsWritable();
fResourceFile = new(std::nothrow) ResourceFile; fResourceFile = new(nothrow) ResourceFile;
if (fResourceFile) if (fResourceFile)
error = fResourceFile->SetTo(&fFile, clobber); error = fResourceFile->SetTo(&fFile, clobber);
else else
@@ -148,7 +149,7 @@ BResources::Unset()
if (fContainer) if (fContainer)
fContainer->MakeEmpty(); fContainer->MakeEmpty();
else else
fContainer = new(std::nothrow) ResourcesContainer; fContainer = new(nothrow) ResourcesContainer;
fReadOnly = false; fReadOnly = false;
} }
@@ -383,7 +384,7 @@ BResources::WriteTo(BFile *file)
// set the new file, but keep the old container // set the new file, but keep the old container
if (error == B_OK) { if (error == B_OK) {
ResourcesContainer *container = fContainer; ResourcesContainer *container = fContainer;
fContainer = new(std::nothrow) ResourcesContainer; fContainer = new(nothrow) ResourcesContainer;
if (fContainer) { if (fContainer) {
error = SetTo(file, false); error = SetTo(file, false);
delete fContainer; delete fContainer;
@@ -425,7 +426,7 @@ BResources::AddResource(type_code type, int32 id, const void *data,
if (error == B_OK) if (error == B_OK)
error = (fReadOnly ? B_NOT_ALLOWED : B_OK); error = (fReadOnly ? B_NOT_ALLOWED : B_OK);
if (error == B_OK) { if (error == B_OK) {
ResourceItem *item = new(std::nothrow) ResourceItem; ResourceItem *item = new(nothrow) ResourceItem;
if (!item) if (!item)
error = B_NO_MEMORY; error = B_NO_MEMORY;
if (error == B_OK) { if (error == B_OK) {
+8 -6
View File
@@ -16,6 +16,8 @@
#include "kernel_interface.h" #include "kernel_interface.h"
#include "storage_support.h" #include "storage_support.h"
using namespace std;
#ifdef USE_OPENBEOS_NAMESPACE #ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS { namespace OpenBeOS {
#endif #endif
@@ -25,7 +27,7 @@ namespace OpenBeOS {
BSymLink::BSymLink() BSymLink::BSymLink()
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry) , fSecretEntry(new(nothrow) BEntry)
{ {
} }
@@ -36,7 +38,7 @@ BSymLink::BSymLink()
BSymLink::BSymLink(const BSymLink &link) BSymLink::BSymLink(const BSymLink &link)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry) , fSecretEntry(new(nothrow) BEntry)
{ {
*this = link; *this = link;
} }
@@ -49,7 +51,7 @@ BSymLink::BSymLink(const BSymLink &link)
BSymLink::BSymLink(const entry_ref *ref) BSymLink::BSymLink(const entry_ref *ref)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry) , fSecretEntry(new(nothrow) BEntry)
{ {
SetTo(ref); SetTo(ref);
} }
@@ -62,7 +64,7 @@ BSymLink::BSymLink(const entry_ref *ref)
BSymLink::BSymLink(const BEntry *entry) BSymLink::BSymLink(const BEntry *entry)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry) , fSecretEntry(new(nothrow) BEntry)
{ {
SetTo(entry); SetTo(entry);
} }
@@ -75,7 +77,7 @@ BSymLink::BSymLink(const BEntry *entry)
BSymLink::BSymLink(const char *path) BSymLink::BSymLink(const char *path)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry) , fSecretEntry(new(nothrow) BEntry)
{ {
SetTo(path); SetTo(path);
} }
@@ -90,7 +92,7 @@ BSymLink::BSymLink(const char *path)
BSymLink::BSymLink(const BDirectory *dir, const char *path) BSymLink::BSymLink(const BDirectory *dir, const char *path)
: BNode() : BNode()
// WORKAROUND // WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry) , fSecretEntry(new(nothrow) BEntry)
{ {
SetTo(dir, path); SetTo(dir, path);
} }
+4 -2
View File
@@ -12,7 +12,7 @@
*/ */
#include <errno.h> #include <errno.h>
#include <new.h> #include <new>
#include <Bitmap.h> #include <Bitmap.h>
#include <Directory.h> #include <Directory.h>
@@ -24,6 +24,8 @@
static const char kBootVolumePath[] = "/boot"; static const char kBootVolumePath[] = "/boot";
using namespace std;
#ifdef USE_OPENBEOS_NAMESPACE #ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS { namespace OpenBeOS {
#endif #endif
@@ -172,7 +174,7 @@ BVolumeRoster::StartWatching(BMessenger messenger)
status_t error = (messenger.IsValid() ? B_OK : B_ERROR); status_t error = (messenger.IsValid() ? B_OK : B_ERROR);
// clone messenger // clone messenger
if (error == B_OK) { if (error == B_OK) {
fTarget = new(std::nothrow) BMessenger(messenger); fTarget = new(nothrow) BMessenger(messenger);
if (!fTarget) if (!fTarget)
error = B_NO_MEMORY; error = B_NO_MEMORY;
} }
+17 -15
View File
@@ -30,6 +30,8 @@
// when all is said and done. // when all is said and done.
#include <iostream> #include <iostream>
using namespace std;
// For convenience: // For convenience:
struct LongDIR : DIR { char _buffer[B_FILE_NAME_LENGTH]; }; struct LongDIR : DIR { char _buffer[B_FILE_NAME_LENGTH]; };
@@ -253,32 +255,32 @@ BPrivate::Storage::sync( FileDescriptor file )
//! /todo Get rid of DumpLock() at some point (it's only for debugging) //! /todo Get rid of DumpLock() at some point (it's only for debugging)
void DumpLock(BPrivate::Storage::FileLock &lock) void DumpLock(BPrivate::Storage::FileLock &lock)
{ {
std::cout << std::endl; cout << endl;
std::cout << "type == "; cout << "type == ";
switch (lock.l_type) { switch (lock.l_type) {
case F_RDLCK: case F_RDLCK:
std::cout << "F_RDLCK"; cout << "F_RDLCK";
break; break;
case F_WRLCK: case F_WRLCK:
std::cout << "F_WRLCK"; cout << "F_WRLCK";
break; break;
case F_UNLCK: case F_UNLCK:
std::cout << "F_UNLCK"; cout << "F_UNLCK";
break; break;
default: default:
std::cout << lock.l_type; cout << lock.l_type;
break; break;
} }
std::cout << std::endl; cout << endl;
std::cout << "whence == " << lock.l_whence << std::endl; cout << "whence == " << lock.l_whence << endl;
std::cout << "start == " << lock.l_start << std::endl; cout << "start == " << lock.l_start << endl;
std::cout << "len == " << lock.l_len << std::endl; cout << "len == " << lock.l_len << endl;
std::cout << "pid == " << lock.l_pid << std::endl; cout << "pid == " << lock.l_pid << endl;
std::cout << std::endl; cout << endl;
} }
// As best I can tell, fcntl(fd, F_SETLK, lock) and fcntl(fd, F_GETLK, lock) // As best I can tell, fcntl(fd, F_SETLK, lock) and fcntl(fd, F_GETLK, lock)
@@ -544,7 +546,7 @@ BPrivate::Storage::rename_attr(FileDescriptor file, const char *oldName,
char *data = NULL; char *data = NULL;
if (error == B_OK) { if (error == B_OK) {
// alloc at least one byte // alloc at least one byte
data = new(std::nothrow) char[max(info.size, 1LL)]; data = new(nothrow) char[max(info.size, 1LL)];
if (data == NULL) if (data == NULL)
error = B_NO_MEMORY; error = B_NO_MEMORY;
} }
@@ -1072,7 +1074,7 @@ BPrivate::Storage::get_canonical_path(const char *path, char *&result)
{ {
status_t error = (path ? B_OK : B_BAD_VALUE); status_t error = (path ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
result = new(std::nothrow) char[B_PATH_NAME_LENGTH]; result = new(nothrow) char[B_PATH_NAME_LENGTH];
if (!result) if (!result)
error = B_NO_MEMORY; error = B_NO_MEMORY;
if (error == B_OK) { if (error == B_OK) {
@@ -1117,7 +1119,7 @@ BPrivate::Storage::get_canonical_dir_path(const char *path, char *&result)
{ {
status_t error = (path ? B_OK : B_BAD_VALUE); status_t error = (path ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
result = new(std::nothrow) char[B_PATH_NAME_LENGTH]; result = new(nothrow) char[B_PATH_NAME_LENGTH];
if (!result) if (!result)
error = B_NO_MEMORY; error = B_NO_MEMORY;
if (error == B_OK) { if (error == B_OK) {
+4 -2
View File
@@ -15,6 +15,8 @@
#include <SupportDefs.h> #include <SupportDefs.h>
#include "storage_support.h" #include "storage_support.h"
using namespace std;
namespace BPrivate { namespace BPrivate {
namespace Storage { namespace Storage {
@@ -232,7 +234,7 @@ parse_first_path_component(const char *path, char *&component,
int32 length; int32 length;
status_t error = parse_first_path_component(path, length, nextComponent); status_t error = parse_first_path_component(path, length, nextComponent);
if (error == B_OK) { if (error == B_OK) {
component = new(std::nothrow) char[length + 1]; component = new(nothrow) char[length + 1];
if (component) { if (component) {
strncpy(component, path, length); strncpy(component, path, length);
component[length] = '\0'; component[length] = '\0';
@@ -376,7 +378,7 @@ void escape_path(const char *str, char *result)
void escape_path(char *str) void escape_path(char *str)
{ {
if (str) { if (str) {
char *copy = new(std::nothrow) char[strlen(str)+1]; char *copy = new(nothrow) char[strlen(str)+1];
if (copy) { if (copy) {
strcpy(copy, str); strcpy(copy, str);
escape_path(copy, str); escape_path(copy, str);