From 2483b1f3813f2dac9bd190dd77b5306bfec240d9 Mon Sep 17 00:00:00 2001 From: terik23 Date: Tue, 2 Apr 2019 01:05:51 +0500 Subject: [PATCH] update readme --- README.md | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5155dd9..a6ed1e6 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,11 @@ |_| \_|\__,_|_| |_| |_|\___|\___/|_| \_____| ``` -Branch | Linux/OSX | Windows | License | Codacy --------|-----------|---------|---------|------- -master |[![Build Status](https://travis-ci.org/Neargye/nameof.svg?branch=master)](https://travis-ci.org/Neargye/nameof)|[![Build status](https://ci.appveyor.com/api/projects/status/yq5fk0d9mwljbubt/branch/master?svg=true)](https://ci.appveyor.com/project/Neargye/nameof/branch/master)|[![License](https://img.shields.io/github/license/Neargye/nameof.svg)](LICENSE)|[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1d06f3f07afe4f34acd29c0c8efa830b)](https://www.codacy.com/app/Neargye/nameof?utm_source=github.com&utm_medium=referral&utm_content=Neargye/nameof&utm_campaign=Badge_Grade) +[![License](https://img.shields.io/github/license/Neargye/nameof.svg)](LICENSE) +[![Build Status](https://travis-ci.org/Neargye/nameof.svg?branch=master)](https://travis-ci.org/Neargye/nameof) +[![Build status](https://ci.appveyor.com/api/projects/status/yq5fk0d9mwljbubt/branch/master?svg=true)](https://ci.appveyor.com/project/Neargye/nameof/branch/master) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1d06f3f07afe4f34acd29c0c8efa830b)](https://www.codacy.com/app/Neargye/nameof?utm_source=github.com&utm_medium=referral&utm_content=Neargye/nameof&utm_campaign=Badge_Grade) +[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/irgD3NwQM2ikhVMC) ## What is Nameof? @@ -34,19 +36,20 @@ Header-only C++17 library provides nameof macros and functions to obtain simple * Name of variable ```cpp -// Name of variable +// Name of variable. NAMEOF(somevar) -> "somevar" -// Name of member variable + +// Name of member variable. NAMEOF(person.address.zip_code) -> "zip_code" ``` * Name of function ```cpp -// Name of function +// Name of function. NAMEOF(foo()) -> "foo" NAMEOF_FULL(foo()) -> "foo" -// Name of member function +// Name of member function. NAMEOF(somevar.some_method()) -> "some_method" NAMEOF_FULL(somevar.some_method()) -> "some_method" ``` @@ -54,38 +57,42 @@ NAMEOF_FULL(somevar.some_method()) -> "some_method" * Name of enum ```cpp auto color = Color::RED; -// Name of enum variable +// Name of enum variable. NAMEOF_ENUM(color) -> "RED" -// Name of enum variable nameof::nameof_enum(color) -> "RED" -constexpr auto cx_color = Color::BLUE; -// Name of static storage enum variable -nameof::nameof_enum() -> "BLUE" +constexpr auto const_color = Color::BLUE; +// Name of static storage enum variable. +NAMEOF_CONST_ENUM(const_color) -> "BLUE" +nameof::nameof_enum() -> "BLUE" ``` * Name of type ```cpp using T = int; T var = 42; -// Name of variable type -NAMEOF_TYPE(var) -> "int" +// Name of variable type. +NAMEOF_VAR_TYPE(var) -> "int" nameof::nameof_type() -> "int" -// Name of type -NAMEOF_TYPE_T(T) -> "int" + +// Name of type. +NAMEOF_TYPE(T) -> "int" nameof::nameof_type() -> "int" ``` * Name of macro ```cpp -// Name of macro +// Name of macro. NAMEOF(__LINE__) -> "__LINE__" +NAMEOF(NAMEOF(structvar)) -> "NAMEOF" ``` ## Remarks * Nameof return std::string_view. +* If arguments does not have name, Nameof return empty string. + * Nameof expression arguments are identified, but do not evaluated. * NAMEOF_ENUM supported on the GCC >= 9. @@ -94,7 +101,7 @@ NAMEOF(__LINE__) -> "__LINE__" ```cpp NAMEOF_RAW(somevar.somefield) -> "somevar.somefield" NAMEOF_RAW(&SomeStruct::SomeMethod) -> "&SomeStruct::SomeMethod" -NAMEOF_RAW(std::string) -> "std::string" +NAMEOF_RAW(const SomeClass volatile *) -> "const SomeClass volatile *" ``` * Spaces and Tabs ignored