3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / kits / debugger / ids / FunctionID.cpp
blob025767dffe190c11cf32f6115b740f45a3b86eed
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "FunctionID.h"
9 #include <new>
11 #include <Message.h>
13 #include "StringUtils.h"
16 // #pragma mark - FunctionID
19 FunctionID::FunctionID(const BMessage& archive)
21 BArchivable(const_cast<BMessage*>(&archive))
23 archive.FindString("FunctionID::path", &fPath);
24 archive.FindString("FunctionID::functionName", &fFunctionName);
28 FunctionID::FunctionID(const BString& path, const BString& functionName)
30 fPath(path),
31 fFunctionName(functionName)
36 FunctionID::~FunctionID()
41 status_t
42 FunctionID::Archive(BMessage* archive, bool deep) const
44 status_t error = BArchivable::Archive(archive, deep);
45 if (error != B_OK)
46 return error;
48 error = archive->AddString("FunctionID::path", fPath);
49 if (error == B_OK)
50 error = archive->AddString("FunctionID::functionName", fFunctionName);
51 return error;
55 uint32
56 FunctionID::ComputeHashValue() const
58 return StringUtils::HashValue(fPath) * 17
59 + StringUtils::HashValue(fFunctionName);
63 bool
64 FunctionID::IsValid() const
66 return !fPath.Length() == 0 && !fFunctionName.Length() == 0;
70 // #pragma mark - SourceFunctionID
73 SourceFunctionID::SourceFunctionID(const BMessage& archive)
75 FunctionID(archive)
80 SourceFunctionID::SourceFunctionID(const BString& sourceFilePath,
81 const BString& functionName)
83 FunctionID(sourceFilePath, functionName)
88 SourceFunctionID::~SourceFunctionID()
93 /*static*/ BArchivable*
94 SourceFunctionID::Instantiate(BMessage* archive)
96 if (archive == NULL)
97 return NULL;
99 SourceFunctionID* object = new(std::nothrow) SourceFunctionID(*archive);
100 if (object == NULL)
101 return NULL;
103 if (!object->IsValid()) {
104 delete object;
105 return NULL;
108 return object;
112 bool
113 SourceFunctionID::operator==(const ObjectID& _other) const
115 const SourceFunctionID* other = dynamic_cast<const SourceFunctionID*>(
116 &_other);
117 return other != NULL && fPath == other->fPath
118 && fFunctionName == other->fFunctionName;
122 // #pragma mark - ImageFunctionID
125 ImageFunctionID::ImageFunctionID(const BMessage& archive)
127 FunctionID(archive)
132 ImageFunctionID::ImageFunctionID(const BString& imageName,
133 const BString& functionName)
135 FunctionID(imageName, functionName)
140 ImageFunctionID::~ImageFunctionID()
145 /*static*/ BArchivable*
146 ImageFunctionID::Instantiate(BMessage* archive)
148 if (archive == NULL)
149 return NULL;
151 ImageFunctionID* object = new(std::nothrow) ImageFunctionID(*archive);
152 if (object == NULL)
153 return NULL;
155 if (!object->IsValid()) {
156 delete object;
157 return NULL;
160 return object;
164 bool
165 ImageFunctionID::operator==(const ObjectID& _other) const
167 const ImageFunctionID* other = dynamic_cast<const ImageFunctionID*>(
168 &_other);
169 return other != NULL && fPath == other->fPath
170 && fFunctionName == other->fFunctionName;