From 715951a775439126211b9ae6c9d306e7cfc5509b Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Thu, 28 Jun 2018 21:56:26 +0200 Subject: [PATCH] document functional and hexavigesimal headers --- alib2std/src/extensions/functional.hpp | 61 +++++++++++++++++++++---- alib2std/src/extensions/hexavigesimal.h | 56 ++++++++++++++++++++++- 2 files changed, 107 insertions(+), 10 deletions(-) diff --git a/alib2std/src/extensions/functional.hpp b/alib2std/src/extensions/functional.hpp index d9e2811545..1383ca1f36 100644 --- a/alib2std/src/extensions/functional.hpp +++ b/alib2std/src/extensions/functional.hpp @@ -1,6 +1,22 @@ /* * functional.hpp * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * * Created on: Apr 1, 2013 * Author: Jan Travnicek */ @@ -12,28 +28,57 @@ namespace ext { +/** + * Class extending the reference wrapper class from the standard library. Original reason is to allow its use with standard stream aggregation class. + * + * The class mimics the behavior of the reference wrapper from the standatd library. + * + * \tparam T the type of the reference inside the reference wrapper + */ template < class T > class reference_wrapper : public std::reference_wrapper < T > { public: -#ifdef __clang__ + /** + * Inherit constructors of the standard reference_wrapper. + */ using std::reference_wrapper < T >::reference_wrapper; + + /** + * Inherit operator = of the standard reference_wrapper. + */ using std::reference_wrapper < T >::operator =; -#else - reference_wrapper ( ) noexcept : std::reference_wrapper < T > ( ) { - } +#ifndef __clang__ + + /** + * Default constructor needed by g++ since it is not inherited. + */ + reference_wrapper ( ) = default; + + /** + * Copy constructor needed by g++ since it is not inherited. + */ reference_wrapper ( const reference_wrapper & other ) = default; + /** + * Move constructor needed by g++ since it is not inherited. + */ reference_wrapper ( reference_wrapper && other ) = default; - using std::reference_wrapper < T >::reference_wrapper; - + /** + * Copy operator = needed by g++ since it is not inherited. + */ reference_wrapper & operator = ( reference_wrapper && other ) = default; + /** + * Move operator = needed by g++ since it is not inherited. + */ reference_wrapper & operator = ( const reference_wrapper & other ) = default; - - using std::reference_wrapper < T >::operator =; #endif + + /** + * Inherit the accessor of the internal reference. + */ using std::reference_wrapper < T >::operator T &; }; diff --git a/alib2std/src/extensions/hexavigesimal.h b/alib2std/src/extensions/hexavigesimal.h index 0b0cd87993..aac258d8cd 100644 --- a/alib2std/src/extensions/hexavigesimal.h +++ b/alib2std/src/extensions/hexavigesimal.h @@ -1,6 +1,22 @@ /* * hexavigesimal.h * + * This file is part of Algorithms library toolkit. + * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) + + * Algorithms library toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * Algorithms library toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. + * * Created on: 19. 4. 2014 * Author: Tomas Pecka */ @@ -13,26 +29,62 @@ namespace ext { /** + * \brief + * Function to convert a number to sequence of uppercase letters. + * + * The following translation is implemented: + * * Maps 0 -> A, 1 -> B, ..., 25 -> Z, 26 -> AB, 27 -> AC, ..., 675 -> ZZ, 676 -> BAA, ... * http://en.wikipedia.org/wiki/Hexavigesimal + * + * \param n the number to convert + * + * \return string sequence corresponding to the value in \p n */ std::string toBase26( unsigned n ); /** + * \brief + * Function to convert sequence of uppercase letters to a number. + * + * The following translation is implemented: + * * Maps A -> 0, B -> 0, ..., Z -> 25, AB -> 26, AC -> 27, ..., ZZ -> 675, BAA -> 676, ... * http://en.wikipedia.org/wiki/Hexavigesimal + * + * \param rep string sequence of uppercase letters + * + * \return the number corresponding to the value in \p rep */ unsigned fromBase26( std::string rep ); /** - * Maps 1 -> A, 2 -> B, ..., 26 -> Z, 27 -> AA, 28 -> AB, ..., 675 -> ZZ, 676 -> BAA, ... + * \brief + * Function to convert a number to sequence of uppercase letters. + * + * The following translation is implemented: + * + * Maps 1 -> A, 2 -> B, ..., 26 -> Z, 27 -> AA, 28 -> AB, ..., 676 -> ZZ, 677 -> AAA, ... * http://en.wikipedia.org/wiki/Hexavigesimal + * + * \param n the number to convert + * + * \return string sequence corresponding to the value in \p n */ std::string bijectiveToBase26( unsigned n ); /** - * Maps 1 -> A, 2 -> B, ..., 26 -> Z, 27 -> AA, AB -> 28, ..., ZZ -> 675, BAA -> 676, ... + * \brief + * Function to convert sequence of uppercase letters to a number. + * + * The following translation is implemented: + * + * Maps 1 -> A, 2 -> B, ..., 26 -> Z, 27 -> AA, AB -> 28, ..., ZZ -> 676, AAA -> 677, ... * http://en.wikipedia.org/wiki/Hexavigesimal + * + * \param rep string sequence of uppercase letters + * + * \return the number corresponding to the value in \p rep */ unsigned bijectiveFromBase26( std::string rep ); -- GitLab