Git object Id.
More...
#include <Git.h>
|
| | ObjectId () |
| | Default constructor.
|
| | ObjectId (const std::string &id) |
| | Construct from a 40-digit hexadecimal number.
|
| std::string | toString () const |
| | Print as a 40-digit hexadecimal number.
|
Git object Id.
Class for compactly storing a 20-byte SHA1 digest.
Definition at line 39 of file Git.h.
◆ ObjectId() [1/2]
| Git::ObjectId::ObjectId |
( |
| ) |
|
Default constructor.
Definition at line 175 of file Git.C.
◆ ObjectId() [2/2]
| Git::ObjectId::ObjectId |
( |
const std::string & | id | ) |
|
|
explicit |
Construct from a 40-digit hexadecimal number.
- Exceptions
-
| Exception | : if the id does not represent a valid SHA1 digest. |
Definition at line 178 of file Git.C.
179{
180 if (id.length() != 40)
181 throw Git::Exception("Git: not a valid SHA1 id: " + id);
182
183 for (int i = 0; i < 20; ++i)
184 (*this)[i] = fromHex(id[2 * i], id[2 * i + 1]);
185}
◆ toString()
| std::string Git::ObjectId::toString |
( |
| ) |
const |
Print as a 40-digit hexadecimal number.
Definition at line 187 of file Git.C.
188{
189 std::string result(40, '-');
190
191 for (int i = 0; i < 20; ++i)
192 toHex((*this)[i], result[2 * i], result[2 * i + 1]);
193
194 return result;
195}
The documentation for this class was generated from the following files: