Style cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35555 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2010-02-21 16:31:50 +00:00
parent cf139460f6
commit 9546aa512f
+72 -66
View File
@@ -37,10 +37,11 @@ using namespace std;
/*! \brief Creates an unitialized BResources object. /*! \brief Creates an unitialized BResources object.
*/ */
BResources::BResources() BResources::BResources()
: fFile(), :
fContainer(NULL), fFile(),
fResourceFile(NULL), fContainer(NULL),
fReadOnly(false) fResourceFile(NULL),
fReadOnly(false)
{ {
fContainer = new(nothrow) ResourcesContainer; fContainer = new(nothrow) ResourcesContainer;
} }
@@ -58,11 +59,12 @@ BResources::BResources()
\param file the file \param file the file
\param clobber if \c true, the file's resources are truncated to size 0 \param clobber if \c true, the file's resources are truncated to size 0
*/ */
BResources::BResources(const BFile *file, bool clobber) BResources::BResources(const BFile* file, bool clobber)
: fFile(), :
fContainer(NULL), fFile(),
fResourceFile(NULL), fContainer(NULL),
fReadOnly(false) fResourceFile(NULL),
fReadOnly(false)
{ {
fContainer = new(nothrow) ResourcesContainer; fContainer = new(nothrow) ResourcesContainer;
SetTo(file, clobber); SetTo(file, clobber);
@@ -78,11 +80,12 @@ BResources::BResources(const BFile *file, bool clobber)
\param path a path referring to the file \param path a path referring to the file
\param clobber if \c true, the file's resources are truncated to size 0 \param clobber if \c true, the file's resources are truncated to size 0
*/ */
BResources::BResources(const char *path, bool clobber) BResources::BResources(const char* path, bool clobber)
: fFile(), :
fContainer(NULL), fFile(),
fResourceFile(NULL), fContainer(NULL),
fReadOnly(false) fResourceFile(NULL),
fReadOnly(false)
{ {
fContainer = new(nothrow) ResourcesContainer; fContainer = new(nothrow) ResourcesContainer;
SetTo(path, clobber); SetTo(path, clobber);
@@ -98,11 +101,12 @@ BResources::BResources(const char *path, bool clobber)
\param ref an entry_ref referring to the file \param ref an entry_ref referring to the file
\param clobber if \c true, the file's resources are truncated to size 0 \param clobber if \c true, the file's resources are truncated to size 0
*/ */
BResources::BResources(const entry_ref *ref, bool clobber) BResources::BResources(const entry_ref* ref, bool clobber)
: fFile(), :
fContainer(NULL), fFile(),
fResourceFile(NULL), fContainer(NULL),
fReadOnly(false) fResourceFile(NULL),
fReadOnly(false)
{ {
fContainer = new(nothrow) ResourcesContainer; fContainer = new(nothrow) ResourcesContainer;
SetTo(ref, clobber); SetTo(ref, clobber);
@@ -140,7 +144,7 @@ BResources::~BResources()
- \c B_ERROR: Failed to initialize the object (for whatever reason). - \c B_ERROR: Failed to initialize the object (for whatever reason).
*/ */
status_t status_t
BResources::SetTo(const BFile *file, bool clobber) BResources::SetTo(const BFile* file, bool clobber)
{ {
Unset(); Unset();
status_t error = B_OK; status_t error = B_OK;
@@ -192,7 +196,7 @@ BResources::SetTo(const BFile *file, bool clobber)
- \c B_ERROR: Failed to initialize the object (for whatever reason). - \c B_ERROR: Failed to initialize the object (for whatever reason).
*/ */
status_t status_t
BResources::SetTo(const char *path, bool clobber) BResources::SetTo(const char* path, bool clobber)
{ {
if (!path) if (!path)
return B_BAD_VALUE; return B_BAD_VALUE;
@@ -227,7 +231,7 @@ BResources::SetTo(const char *path, bool clobber)
- \c B_ERROR: Failed to initialize the object (for whatever reason). - \c B_ERROR: Failed to initialize the object (for whatever reason).
*/ */
status_t status_t
BResources::SetTo(const entry_ref *ref, bool clobber) BResources::SetTo(const entry_ref* ref, bool clobber)
{ {
if (!ref) if (!ref)
return B_BAD_VALUE; return B_BAD_VALUE;
@@ -285,7 +289,7 @@ BResources::SetToImage(image_id image, bool clobber)
- \c B_ERROR: Failed to initialize the object (for whatever reason). - \c B_ERROR: Failed to initialize the object (for whatever reason).
*/ */
status_t status_t
BResources::SetToImage(const void *codeOrDataPointer, bool clobber) BResources::SetToImage(const void* codeOrDataPointer, bool clobber)
{ {
if (!codeOrDataPointer) if (!codeOrDataPointer)
return B_BAD_VALUE; return B_BAD_VALUE;
@@ -349,7 +353,7 @@ BResources::InitCheck() const
/*! \brief Returns a reference to the BResources' BFile object. /*! \brief Returns a reference to the BResources' BFile object.
\return a reference to the object's BFile. \return a reference to the object's BFile.
*/ */
const BFile & const BFile&
BResources::File() const BResources::File() const
{ {
return fFile; return fFile;
@@ -369,12 +373,12 @@ BResources::File() const
\c NULL, if the file does not have a resource that matchs the \c NULL, if the file does not have a resource that matchs the
parameters or an error occured. parameters or an error occured.
*/ */
const void * const void*
BResources::LoadResource(type_code type, int32 id, size_t *outSize) BResources::LoadResource(type_code type, int32 id, size_t* outSize)
{ {
// find the resource // find the resource
status_t error = InitCheck(); status_t error = InitCheck();
ResourceItem *resource = NULL; ResourceItem* resource = NULL;
if (error == B_OK) { if (error == B_OK) {
resource = fContainer->ResourceAt(fContainer->IndexOf(type, id)); resource = fContainer->ResourceAt(fContainer->IndexOf(type, id));
if (!resource) if (!resource)
@@ -411,11 +415,11 @@ BResources::LoadResource(type_code type, int32 id, size_t *outSize)
parameters, that is the one with the least index. parameters, that is the one with the least index.
*/ */
const void * const void *
BResources::LoadResource(type_code type, const char *name, size_t *outSize) BResources::LoadResource(type_code type, const char* name, size_t* outSize)
{ {
// find the resource // find the resource
status_t error = InitCheck(); status_t error = InitCheck();
ResourceItem *resource = NULL; ResourceItem* resource = NULL;
if (error == B_OK) { if (error == B_OK) {
resource = fContainer->ResourceAt(fContainer->IndexOf(type, name)); resource = fContainer->ResourceAt(fContainer->IndexOf(type, name));
if (!resource) if (!resource)
@@ -425,7 +429,7 @@ BResources::LoadResource(type_code type, const char *name, size_t *outSize)
if (error == B_OK && !resource->IsLoaded() && fResourceFile) if (error == B_OK && !resource->IsLoaded() && fResourceFile)
error = fResourceFile->ReadResource(*resource); error = fResourceFile->ReadResource(*resource);
// return the result // return the result
const void *result = NULL; const void* result = NULL;
if (error == B_OK) { if (error == B_OK) {
result = resource->Data(); result = resource->Data();
if (outSize) if (outSize)
@@ -515,7 +519,7 @@ BResources::Sync()
- \c B_IO_ERROR: An error occured while writing the resources. - \c B_IO_ERROR: An error occured while writing the resources.
*/ */
status_t status_t
BResources::MergeFrom(BFile *fromFile) BResources::MergeFrom(BFile* fromFile)
{ {
status_t error = (fromFile ? B_OK : B_BAD_VALUE); status_t error = (fromFile ? B_OK : B_BAD_VALUE);
if (error == B_OK) if (error == B_OK)
@@ -546,7 +550,7 @@ BResources::MergeFrom(BFile *fromFile)
remains unmodified. remains unmodified.
*/ */
status_t status_t
BResources::WriteTo(BFile *file) BResources::WriteTo(BFile* file)
{ {
status_t error = (file ? B_OK : B_BAD_VALUE); status_t error = (file ? B_OK : B_BAD_VALUE);
if (error == B_OK) if (error == B_OK)
@@ -592,8 +596,8 @@ BResources::WriteTo(BFile *file)
- \c B_NO_MEMORY: Not enough memory for that operation. - \c B_NO_MEMORY: Not enough memory for that operation.
*/ */
status_t status_t
BResources::AddResource(type_code type, int32 id, const void *data, BResources::AddResource(type_code type, int32 id, const void* data,
size_t length, const char *name) size_t length, const char* name)
{ {
status_t error = (data ? B_OK : B_BAD_VALUE); status_t error = (data ? B_OK : B_BAD_VALUE);
if (error == B_OK) if (error == B_OK)
@@ -601,7 +605,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(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) {
@@ -643,7 +647,7 @@ BResources::HasResource(type_code type, int32 id)
\return \c true, if the file contains a matching resource, \false otherwise \return \c true, if the file contains a matching resource, \false otherwise
*/ */
bool bool
BResources::HasResource(type_code type, const char *name) BResources::HasResource(type_code type, const char* name)
{ {
return (InitCheck() == B_OK && fContainer->IndexOf(type, name) >= 0); return (InitCheck() == B_OK && fContainer->IndexOf(type, name) >= 0);
} }
@@ -662,11 +666,11 @@ BResources::HasResource(type_code type, const char *name)
\return \c true, if a matching resource could be found, false otherwise \return \c true, if a matching resource could be found, false otherwise
*/ */
bool bool
BResources::GetResourceInfo(int32 byIndex, type_code *typeFound, BResources::GetResourceInfo(int32 byIndex, type_code* typeFound,
int32 *idFound, const char **nameFound, int32* idFound, const char** nameFound,
size_t *lengthFound) size_t* lengthFound)
{ {
ResourceItem *item = NULL; ResourceItem* item = NULL;
if (InitCheck() == B_OK) if (InitCheck() == B_OK)
item = fContainer->ResourceAt(byIndex); item = fContainer->ResourceAt(byIndex);
if (item) { if (item) {
@@ -696,10 +700,10 @@ BResources::GetResourceInfo(int32 byIndex, type_code *typeFound,
\return \c true, if a matching resource could be found, false otherwise \return \c true, if a matching resource could be found, false otherwise
*/ */
bool bool
BResources::GetResourceInfo(type_code byType, int32 andIndex, int32 *idFound, BResources::GetResourceInfo(type_code byType, int32 andIndex, int32* idFound,
const char **nameFound, size_t *lengthFound) const char** nameFound, size_t* lengthFound)
{ {
ResourceItem *item = NULL; ResourceItem* item = NULL;
if (InitCheck() == B_OK) { if (InitCheck() == B_OK) {
item = fContainer->ResourceAt(fContainer->IndexOfType(byType, item = fContainer->ResourceAt(fContainer->IndexOfType(byType,
andIndex)); andIndex));
@@ -727,9 +731,9 @@ BResources::GetResourceInfo(type_code byType, int32 andIndex, int32 *idFound,
*/ */
bool bool
BResources::GetResourceInfo(type_code byType, int32 andID, BResources::GetResourceInfo(type_code byType, int32 andID,
const char **nameFound, size_t *lengthFound) const char** nameFound, size_t* lengthFound)
{ {
ResourceItem *item = NULL; ResourceItem* item = NULL;
if (InitCheck() == B_OK) if (InitCheck() == B_OK)
item = fContainer->ResourceAt(fContainer->IndexOf(byType, andID)); item = fContainer->ResourceAt(fContainer->IndexOf(byType, andID));
if (item) { if (item) {
@@ -753,10 +757,10 @@ BResources::GetResourceInfo(type_code byType, int32 andID,
\return \c true, if a matching resource could be found, false otherwise \return \c true, if a matching resource could be found, false otherwise
*/ */
bool bool
BResources::GetResourceInfo(type_code byType, const char *andName, BResources::GetResourceInfo(type_code byType, const char* andName,
int32 *idFound, size_t *lengthFound) int32* idFound, size_t* lengthFound)
{ {
ResourceItem *item = NULL; ResourceItem* item = NULL;
if (InitCheck() == B_OK) if (InitCheck() == B_OK)
item = fContainer->ResourceAt(fContainer->IndexOf(byType, andName)); item = fContainer->ResourceAt(fContainer->IndexOf(byType, andName));
if (item) { if (item) {
@@ -783,11 +787,11 @@ BResources::GetResourceInfo(type_code byType, const char *andName,
\return \c true, if a matching resource could be found, false otherwise \return \c true, if a matching resource could be found, false otherwise
*/ */
bool bool
BResources::GetResourceInfo(const void *byPointer, type_code *typeFound, BResources::GetResourceInfo(const void* byPointer, type_code* typeFound,
int32 *idFound, size_t *lengthFound, int32* idFound, size_t* lengthFound,
const char **nameFound) const char** nameFound)
{ {
ResourceItem *item = NULL; ResourceItem* item = NULL;
if (InitCheck() == B_OK) if (InitCheck() == B_OK)
item = fContainer->ResourceAt(fContainer->IndexOf(byPointer)); item = fContainer->ResourceAt(fContainer->IndexOf(byPointer));
if (item) { if (item) {
@@ -816,7 +820,7 @@ BResources::GetResourceInfo(const void *byPointer, type_code *typeFound,
- \c B_ERROR: An error occured while removing the resource. - \c B_ERROR: An error occured while removing the resource.
*/ */
status_t status_t
BResources::RemoveResource(const void *resource) BResources::RemoveResource(const void* resource)
{ {
status_t error = (resource ? B_OK : B_BAD_VALUE); status_t error = (resource ? B_OK : B_BAD_VALUE);
if (error == B_OK) if (error == B_OK)
@@ -824,7 +828,7 @@ BResources::RemoveResource(const void *resource)
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 ResourceItem* item
= fContainer->RemoveResource(fContainer->IndexOf(resource)); = fContainer->RemoveResource(fContainer->IndexOf(resource));
if (item) if (item)
delete item; delete item;
@@ -852,7 +856,7 @@ BResources::RemoveResource(type_code type, int32 id)
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 ResourceItem* item
= fContainer->RemoveResource(fContainer->IndexOf(type, id)); = fContainer->RemoveResource(fContainer->IndexOf(type, id));
if (item) if (item)
delete item; delete item;
@@ -885,7 +889,7 @@ BResources::RemoveResource(type_code type, int32 id)
\deprecated Always use AddResource(). \deprecated Always use AddResource().
*/ */
status_t status_t
BResources::WriteResource(type_code type, int32 id, const void *data, BResources::WriteResource(type_code type, int32 id, const void* data,
off_t offset, size_t length) off_t offset, size_t length)
{ {
status_t error = (data && offset >= 0 ? B_OK : B_BAD_VALUE); status_t error = (data && offset >= 0 ? B_OK : B_BAD_VALUE);
@@ -934,13 +938,13 @@ BResources::WriteResource(type_code type, int32 id, const void *data,
\deprecated Use LoadResource() only. \deprecated Use LoadResource() only.
*/ */
status_t status_t
BResources::ReadResource(type_code type, int32 id, void *data, off_t offset, BResources::ReadResource(type_code type, int32 id, void* data, off_t offset,
size_t length) size_t length)
{ {
status_t error = (data && offset >= 0 ? B_OK : B_BAD_VALUE); status_t error = (data && offset >= 0 ? B_OK : B_BAD_VALUE);
if (error == B_OK) if (error == B_OK)
error = InitCheck(); error = InitCheck();
ResourceItem *item = NULL; ResourceItem* item = NULL;
if (error == B_OK) { if (error == B_OK) {
item = fContainer->ResourceAt(fContainer->IndexOf(type, id)); item = fContainer->ResourceAt(fContainer->IndexOf(type, id));
if (!item) if (!item)
@@ -971,12 +975,13 @@ BResources::ReadResource(type_code type, int32 id, void *data, off_t offset,
- \c NULL, if an error occured. - \c NULL, if an error occured.
\deprecated Use LoadResource(). \deprecated Use LoadResource().
*/ */
void * void*
BResources::FindResource(type_code type, int32 id, size_t *lengthFound) BResources::FindResource(type_code type, int32 id, size_t* lengthFound)
{ {
void *result = NULL; void* result = NULL;
size_t size = 0; size_t size = 0;
if (const void *data = LoadResource(type, id, &size)) { const void* data = LoadResource(type, id, &size);
if (data != NULL) {
if ((result = malloc(size))) if ((result = malloc(size)))
memcpy(result, data, size); memcpy(result, data, size);
} }
@@ -997,12 +1002,13 @@ BResources::FindResource(type_code type, int32 id, size_t *lengthFound)
- \c NULL, if an error occured. - \c NULL, if an error occured.
\deprecated Use LoadResource(). \deprecated Use LoadResource().
*/ */
void * void*
BResources::FindResource(type_code type, const char *name, size_t *lengthFound) BResources::FindResource(type_code type, const char* name, size_t* lengthFound)
{ {
void *result = NULL; void* result = NULL;
size_t size = 0; size_t size = 0;
if (const void *data = LoadResource(type, name, &size)) { const void *data = LoadResource(type, name, &size);
if (data != NULL) {
if ((result = malloc(size))) if ((result = malloc(size)))
memcpy(result, data, size); memcpy(result, data, size);
} }