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

View File

@ -22,6 +22,8 @@
using namespace OpenBeOS;
#endif
using namespace std;
// SYMLINK_MAX is needed by B_SYMLINK_MAX
// I don't know, why it isn't defined.
#ifndef SYMLINK_MAX
@ -114,7 +116,7 @@ status_t entry_ref::set_name(const char *name)
if (name == NULL) {
this->name = NULL;
} else {
this->name = new(std::nothrow) char[strlen(name)+1];
this->name = new(nothrow) char[strlen(name)+1];
if (this->name == NULL)
return B_NO_MEMORY;
strcpy(this->name, name);
@ -1047,7 +1049,7 @@ BEntry::set_name(const char *name)
delete [] fName;
}
fName = new(std::nothrow) char[strlen(name)+1];
fName = new(nothrow) char[strlen(name)+1];
if (fName == NULL)
return B_NO_MEMORY;

View File

@ -14,7 +14,7 @@
#include <sniffer/Parser.h>
#include <ctype.h> // For tolower()
#include <new.h> // For new(nothrow)
#include <new> // For new(nothrow)
#include <stdio.h> // For printf()
#include <string.h> // For strncpy()
#include <RegistrarDefs.h>
@ -29,6 +29,7 @@ enum {
};
using namespace BPrivate::Storage::Mime;
using namespace std;
const char *B_PEF_APP_MIME_TYPE = "application/x-be-executable";
const char *B_PE_APP_MIME_TYPE = "application/x-vnd.be-peexecutable";

View File

@ -19,6 +19,8 @@
#include <fs_attr.h>
using namespace std;
// attribute names
#define NI_BEOS "BEOS"
static const char *kNITypeAttribute = NI_BEOS ":TYPE";

View File

@ -17,6 +17,8 @@
#include "kernel_interface.h"
#include "storage_support.h"
using namespace std;
#ifdef USE_OPENBEOS_NAMESPACE
using namespace OpenBeOS;
#endif
@ -600,7 +602,7 @@ BPath::set_path(const char *path)
const char *oldPath = fName;
// set the new path
if (path) {
fName = new(std::nothrow) char[strlen(path) + 1];
fName = new(nothrow) char[strlen(path) + 1];
if (fName)
strcpy(fName, path);
else

View File

@ -20,6 +20,7 @@
#include "QueryPredicate.h"
using namespace BPrivate::Storage;
using namespace std;
enum {
@ -95,7 +96,7 @@ BQuery::Clear()
status_t
BQuery::PushAttr(const char *attrName)
{
return _PushNode(new(std::nothrow) AttributeNode(attrName), true);
return _PushNode(new(nothrow) AttributeNode(attrName), true);
}
// PushOp
@ -129,13 +130,13 @@ BQuery::PushOp(query_op op)
case B_ENDS_WITH:
case B_AND:
case B_OR:
error = _PushNode(new(std::nothrow) BinaryOpNode(op), true);
error = _PushNode(new(nothrow) BinaryOpNode(op), true);
break;
case B_NOT:
error = _PushNode(new(std::nothrow) UnaryOpNode(op), true);
error = _PushNode(new(nothrow) UnaryOpNode(op), true);
break;
default:
error = _PushNode(new(std::nothrow) SpecialOpNode(op), true);
error = _PushNode(new(nothrow) SpecialOpNode(op), true);
break;
}
return error;
@ -159,7 +160,7 @@ BQuery::PushOp(query_op op)
status_t
BQuery::PushUInt32(uint32 value)
{
return _PushNode(new(std::nothrow) UInt32ValueNode(value), true);
return _PushNode(new(nothrow) UInt32ValueNode(value), true);
}
// PushInt32
@ -180,7 +181,7 @@ BQuery::PushUInt32(uint32 value)
status_t
BQuery::PushInt32(int32 value)
{
return _PushNode(new(std::nothrow) Int32ValueNode(value), true);
return _PushNode(new(nothrow) Int32ValueNode(value), true);
}
// PushUInt64
@ -201,7 +202,7 @@ BQuery::PushInt32(int32 value)
status_t
BQuery::PushUInt64(uint64 value)
{
return _PushNode(new(std::nothrow) UInt64ValueNode(value), true);
return _PushNode(new(nothrow) UInt64ValueNode(value), true);
}
// PushInt64
@ -222,7 +223,7 @@ BQuery::PushUInt64(uint64 value)
status_t
BQuery::PushInt64(int64 value)
{
return _PushNode(new(std::nothrow) Int64ValueNode(value), true);
return _PushNode(new(nothrow) Int64ValueNode(value), true);
}
// PushFloat
@ -243,7 +244,7 @@ BQuery::PushInt64(int64 value)
status_t
BQuery::PushFloat(float value)
{
return _PushNode(new(std::nothrow) FloatValueNode(value), true);
return _PushNode(new(nothrow) FloatValueNode(value), true);
}
// PushDouble
@ -264,7 +265,7 @@ BQuery::PushFloat(float value)
status_t
BQuery::PushDouble(double value)
{
return _PushNode(new(std::nothrow) DoubleValueNode(value), true);
return _PushNode(new(nothrow) DoubleValueNode(value), true);
}
// PushString
@ -287,7 +288,7 @@ BQuery::PushDouble(double value)
status_t
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
@ -319,7 +320,7 @@ BQuery::PushDate(const char *date)
}
}
if (error == B_OK)
error = _PushNode(new(std::nothrow) DateNode(date), true);
error = _PushNode(new(nothrow) DateNode(date), true);
return error;
}
@ -677,7 +678,7 @@ BQuery::_PushNode(QueryNode *node, bool deleteOnError)
error = B_NOT_ALLOWED;
// allocate the stack, if necessary
if (error == B_OK && !fStack) {
fStack = new(std::nothrow) QueryStack;
fStack = new(nothrow) QueryStack;
if (!fStack)
error = B_NO_MEMORY;
}
@ -705,7 +706,7 @@ BQuery::_SetPredicate(const char *expression)
fPredicate = NULL;
// set the new one
if (expression) {
fPredicate = new(std::nothrow) char[strlen(expression) + 1];
fPredicate = new(nothrow) char[strlen(expression) + 1];
if (fPredicate)
strcpy(fPredicate, expression);
else

View File

@ -7,9 +7,9 @@
ResourceFile implementation.
*/
#include "ResourceFile.h"
#include <ResourceFile.h>
#include <algobase.h>
#include <algorithm>
#include <new>
#include <stdio.h>
@ -21,6 +21,8 @@
#include "ResourcesDefs.h"
//#include "Warnings.h"
using namespace std;
namespace BPrivate {
namespace Storage {
@ -822,7 +824,7 @@ ResourceFile::_ReadIndexEntry(resource_parse_info &parseInfo, int32 index,
}
// add the entry
if (result) {
ResourceItem *item = new(std::nothrow) ResourceItem;
ResourceItem *item = new(nothrow) ResourceItem;
if (!item)
throw Exception(B_NO_MEMORY);
item->SetLocation(offset, size);
@ -841,7 +843,7 @@ ResourceFile::_ReadInfoTable(resource_parse_info &parseInfo)
int32 &resourceCount = parseInfo.resource_count;
// read the info 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)
throw Exception(B_NO_MEMORY);
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,
"Failed to read resource info table.");
//
bool *readIndices = new(std::nothrow) bool[resourceCount + 1];
bool *readIndices = new(nothrow) bool[resourceCount + 1];
// + 1 => always > 0
if (!readIndices)
throw Exception(B_NO_MEMORY);
@ -1074,7 +1076,7 @@ ResourceFile::_WriteResources(ResourcesContainer &container)
// write...
// set the file size
fFile.SetSize(size);
buffer = new(std::nothrow) char[bufferSize];
buffer = new(nothrow) char[bufferSize];
if (!buffer)
throw Exception(B_NO_MEMORY);
void *data = buffer;

View File

@ -19,6 +19,9 @@
#include "kernel_interface.h"
using namespace std;
// constructor
/*! \brief Creates an object initialized to the application's string resources.
*/

View File

@ -25,6 +25,7 @@
#include "ResourcesContainer.h"
using namespace BPrivate::Storage;
using namespace std;
enum {
NOT_IMPLEMENTED = B_ERROR,
@ -39,7 +40,7 @@ BResources::BResources()
fResourceFile(NULL),
fReadOnly(false)
{
fContainer = new(std::nothrow) ResourcesContainer;
fContainer = new(nothrow) ResourcesContainer;
}
// constructor
@ -61,7 +62,7 @@ BResources::BResources(const BFile *file, bool clobber)
fResourceFile(NULL),
fReadOnly(false)
{
fContainer = new(std::nothrow) ResourcesContainer;
fContainer = new(nothrow) ResourcesContainer;
SetTo(file, clobber);
}
@ -109,7 +110,7 @@ BResources::SetTo(const BFile *file, bool clobber)
}
if (error == B_OK) {
fReadOnly = !fFile.IsWritable();
fResourceFile = new(std::nothrow) ResourceFile;
fResourceFile = new(nothrow) ResourceFile;
if (fResourceFile)
error = fResourceFile->SetTo(&fFile, clobber);
else
@ -148,7 +149,7 @@ BResources::Unset()
if (fContainer)
fContainer->MakeEmpty();
else
fContainer = new(std::nothrow) ResourcesContainer;
fContainer = new(nothrow) ResourcesContainer;
fReadOnly = false;
}
@ -383,7 +384,7 @@ BResources::WriteTo(BFile *file)
// set the new file, but keep the old container
if (error == B_OK) {
ResourcesContainer *container = fContainer;
fContainer = new(std::nothrow) ResourcesContainer;
fContainer = new(nothrow) ResourcesContainer;
if (fContainer) {
error = SetTo(file, false);
delete fContainer;
@ -425,7 +426,7 @@ BResources::AddResource(type_code type, int32 id, const void *data,
if (error == B_OK)
error = (fReadOnly ? B_NOT_ALLOWED : B_OK);
if (error == B_OK) {
ResourceItem *item = new(std::nothrow) ResourceItem;
ResourceItem *item = new(nothrow) ResourceItem;
if (!item)
error = B_NO_MEMORY;
if (error == B_OK) {

View File

@ -16,6 +16,8 @@
#include "kernel_interface.h"
#include "storage_support.h"
using namespace std;
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
@ -25,7 +27,7 @@ namespace OpenBeOS {
BSymLink::BSymLink()
: BNode()
// WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry)
, fSecretEntry(new(nothrow) BEntry)
{
}
@ -36,7 +38,7 @@ BSymLink::BSymLink()
BSymLink::BSymLink(const BSymLink &link)
: BNode()
// WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry)
, fSecretEntry(new(nothrow) BEntry)
{
*this = link;
}
@ -49,7 +51,7 @@ BSymLink::BSymLink(const BSymLink &link)
BSymLink::BSymLink(const entry_ref *ref)
: BNode()
// WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry)
, fSecretEntry(new(nothrow) BEntry)
{
SetTo(ref);
}
@ -62,7 +64,7 @@ BSymLink::BSymLink(const entry_ref *ref)
BSymLink::BSymLink(const BEntry *entry)
: BNode()
// WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry)
, fSecretEntry(new(nothrow) BEntry)
{
SetTo(entry);
}
@ -75,7 +77,7 @@ BSymLink::BSymLink(const BEntry *entry)
BSymLink::BSymLink(const char *path)
: BNode()
// WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry)
, fSecretEntry(new(nothrow) BEntry)
{
SetTo(path);
}
@ -90,7 +92,7 @@ BSymLink::BSymLink(const char *path)
BSymLink::BSymLink(const BDirectory *dir, const char *path)
: BNode()
// WORKAROUND
, fSecretEntry(new(std::nothrow) BEntry)
, fSecretEntry(new(nothrow) BEntry)
{
SetTo(dir, path);
}

View File

@ -12,7 +12,7 @@
*/
#include <errno.h>
#include <new.h>
#include <new>
#include <Bitmap.h>
#include <Directory.h>
@ -24,6 +24,8 @@
static const char kBootVolumePath[] = "/boot";
using namespace std;
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
@ -172,7 +174,7 @@ BVolumeRoster::StartWatching(BMessenger messenger)
status_t error = (messenger.IsValid() ? B_OK : B_ERROR);
// clone messenger
if (error == B_OK) {
fTarget = new(std::nothrow) BMessenger(messenger);
fTarget = new(nothrow) BMessenger(messenger);
if (!fTarget)
error = B_NO_MEMORY;
}

View File

@ -30,6 +30,8 @@
// when all is said and done.
#include <iostream>
using namespace std;
// For convenience:
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)
void DumpLock(BPrivate::Storage::FileLock &lock)
{
std::cout << std::endl;
std::cout << "type == ";
cout << endl;
cout << "type == ";
switch (lock.l_type) {
case F_RDLCK:
std::cout << "F_RDLCK";
cout << "F_RDLCK";
break;
case F_WRLCK:
std::cout << "F_WRLCK";
cout << "F_WRLCK";
break;
case F_UNLCK:
std::cout << "F_UNLCK";
cout << "F_UNLCK";
break;
default:
std::cout << lock.l_type;
cout << lock.l_type;
break;
}
std::cout << std::endl;
cout << endl;
std::cout << "whence == " << lock.l_whence << std::endl;
std::cout << "start == " << lock.l_start << std::endl;
std::cout << "len == " << lock.l_len << std::endl;
std::cout << "pid == " << lock.l_pid << std::endl;
std::cout << std::endl;
cout << "whence == " << lock.l_whence << endl;
cout << "start == " << lock.l_start << endl;
cout << "len == " << lock.l_len << endl;
cout << "pid == " << lock.l_pid << endl;
cout << endl;
}
// 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;
if (error == B_OK) {
// 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)
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);
if (error == B_OK) {
result = new(std::nothrow) char[B_PATH_NAME_LENGTH];
result = new(nothrow) char[B_PATH_NAME_LENGTH];
if (!result)
error = B_NO_MEMORY;
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);
if (error == B_OK) {
result = new(std::nothrow) char[B_PATH_NAME_LENGTH];
result = new(nothrow) char[B_PATH_NAME_LENGTH];
if (!result)
error = B_NO_MEMORY;
if (error == B_OK) {

View File

@ -15,6 +15,8 @@
#include <SupportDefs.h>
#include "storage_support.h"
using namespace std;
namespace BPrivate {
namespace Storage {
@ -232,7 +234,7 @@ parse_first_path_component(const char *path, char *&component,
int32 length;
status_t error = parse_first_path_component(path, length, nextComponent);
if (error == B_OK) {
component = new(std::nothrow) char[length + 1];
component = new(nothrow) char[length + 1];
if (component) {
strncpy(component, path, length);
component[length] = '\0';
@ -376,7 +378,7 @@ void escape_path(const char *str, char *result)
void escape_path(char *str)
{
if (str) {
char *copy = new(std::nothrow) char[strlen(str)+1];
char *copy = new(nothrow) char[strlen(str)+1];
if (copy) {
strcpy(copy, str);
escape_path(copy, str);