Wt examples  4.10.4
Public Member Functions | List of all members
Git::ObjectId Class Reference

Git object Id. More...

#include <Git.h>

Inheritance diagram for Git::ObjectId:
[legend]

Public Member Functions

 ObjectId ()
 Default constructor. More...
 
 ObjectId (const std::string &id)
 Construct from a 40-digit hexadecimal number. More...
 
std::string toString () const
 Print as a 40-digit hexadecimal number. More...
 

Detailed Description

Git object Id.

Class for compactly storing a 20-byte SHA1 digest.

Definition at line 39 of file Git.h.

Constructor & Destructor Documentation

◆ ObjectId() [1/2]

Git::ObjectId::ObjectId ( )

Default constructor.

Definition at line 173 of file Git.C.

174 { }

◆ 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 176 of file Git.C.

177 {
178  if (id.length() != 40)
179  throw Git::Exception("Git: not a valid SHA1 id: " + id);
180 
181  for (int i = 0; i < 20; ++i)
182  (*this)[i] = fromHex(id[2 * i], id[2 * i + 1]);
183 }
Exception class.
Definition: Git.h:28

Member Function Documentation

◆ toString()

std::string Git::ObjectId::toString ( ) const

Print as a 40-digit hexadecimal number.

Definition at line 185 of file Git.C.

186 {
187  std::string result(40, '-');
188 
189  for (int i = 0; i < 20; ++i)
190  toHex((*this)[i], result[2 * i], result[2 * i + 1]);
191 
192  return result;
193 }

The documentation for this class was generated from the following files: