Skip to content

AUuid#

Implements universally unique identifier (UUID)

Header:#include <AUI/Common/AUuid.h>
CMake:aui_link(my_target PUBLIC aui::core)

Detailed Description#

A UUID can be parsed from a canonical (8-4-4-4-12) or raw (32 hex digits) string and printed in either format. Invalid input makes the constructor throw AUuidException.

1
2
3
AString s = "123e4567-e89b-12d3-a456-426655440000";
AUuid uuid = s;
ASSERT_EQ(uuid.toString(), s);

To generate a random UUID, use ARandom::nextUuid().

Public Methods#

constructor#


AUuid::AUuid(const AString& s)
Arguments
s
string representing UUID

Construct UUID value from string. Supported the following formats:

  • Canonical: 8-4-4-4-12 (123e4567-e89b-12d3-a456-426655440000)
  • Raw: 32 (123e4567e89b12d3a456426655440000)

fromString#


static AUuid AUuid::fromString(const AString& string)
Arguments
string
Returns
generated UUID.

Converts a string to UUID. If the string is a valid UUID it is converted to the matching AUuid value else a new UUID generated from the string contents.

Examples:

examples/ui/contacts/src/main.cpp

AUI Contacts — Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

                          Vertical {
                            SpacerFixed(8_dp),
                            _new<ATextField>() && mSearchQuery,
                            SpacerFixed(8_dp),
                            AText::fromString(predefined::DISCLAIMER) AUI_OVERRIDE_STYLE { ATextAlign::CENTER },
                            SpacerFixed(8_dp),
                            experimental::Dynamic {
                                .content = AUI_REACT(mSearchQuery->empty() ? indexedList() : searchQueryList()),
                            },
                            Label { AUI_REACT("{} contact(s)"_format(mContactCount)) } AUI_LET {
examples/ui/backdrop/src/main.cpp

Backdrop — Backdrop effects demo.

          Vertical::Expanding {
            Centered {
              Icon { ":logo.svg" } AUI_OVERRIDE_STYLE { FixedSize { 128_dp } },
            } AUI_OVERRIDE_STYLE { FixedSize { 500_dp, {} } },
            AText::fromString(
                "    — Eh bien, mon prince. Gênes et Lucques ne sont plus que des apanages, des "
                "поместья, de la famille Buonaparte. Non, je vous préviens que si vous ne me dites pas "
                "que nous avons la guerre, si vous vous permettez encore de pallier toutes les infamies, "
                "toutes les atrocités de cet Antichrist (ma parole, j'y crois) — je ne vous connais "
                "plus, vous n'êtes plus mon ami, vous n'êtes plus мой верный раб, comme vous dites 1. "
examples/ui/views/src/ExampleWindow.cpp

Views Example — All-in-one views building example.

    });

    addView(Horizontal {
      _new<ADrawableView>(IDrawable::fromUrl(":img/logo.svg")) AUI_OVERRIDE_STYLE { FixedSize { 32_dp } },
      AText::fromString("Building beautiful programs in pure C++ without chromium embedded framework") AUI_OVERRIDE_STYLE {
        Expanding(1, 1),
      },
      Horizontal {} AUI_LET {
              mAsync << AUI_THREADPOOL {
                  auto drawable = IDrawable::fromUrl(

toRawString#


AString AUuid::toRawString()
Returns
uuid string in raw format

toString#


AString AUuid::toString()
Returns
uuid string in canonical format

Examples: