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

Git object Id. More...

#include <Git.h>

Inheritance diagram for Git::ObjectId:
Inheritance graph
[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

Git::ObjectId::ObjectId ( )

Default constructor.

Definition at line 174 of file Git.C.

175 { }
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 177 of file Git.C.

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

Member Function Documentation

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

Print as a 40-digit hexadecimal number.

Definition at line 186 of file Git.C.

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

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

Generated on Mon Sep 4 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11