diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2017-04-30 19:50:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-05-02 08:18:14 +0200 |
commit | a12dfa353122d1865b7c20513865a4632a621a38 (patch) | |
tree | d37bb405e7f7783050a26b8fd98b39746cb3e278 /include/sfx2/groupid.hxx | |
parent | 5eaad8eb1d46b6f85605c5ac210e8b1397b18b22 (diff) |
create SfxGroupId based on o3tl::strong_int
Change-Id: Iaccf16f29b6f4b1a2c712d1e5e2bd0fa4fdb5e71
Reviewed-on: https://gerrit.libreoffice.org/37108
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/sfx2/groupid.hxx')
-rw-r--r-- | include/sfx2/groupid.hxx | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/include/sfx2/groupid.hxx b/include/sfx2/groupid.hxx new file mode 100644 index 000000000000..072ac723319b --- /dev/null +++ b/include/sfx2/groupid.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_GROUPID_HXX +#define INCLUDED_SFX2_GROUPID_HXX + +#ifdef __RSC +#define SfxGroupId(x) (x) +#else + +#include <o3tl/strong_int.hxx> +#include <sal/types.h> +#include <functional> + +struct SfxGroupIdTag {}; +typedef o3tl::strong_int<sal_uInt16, SfxGroupIdTag> SfxGroupId; + +// make it hashable for storing in maps +namespace std { + + template <> + struct hash<SfxGroupId> + { + std::size_t operator()(const SfxGroupId& k) const + { + return std::hash<sal_uInt16>()((sal_uInt16)k); + } + }; + +} + +// Make it easier to declare the constants in the .hrc files. +// This way, we only have to mark the START constant as being SfxGroupId. +inline SfxGroupId operator+(SfxGroupId lhs, sal_uInt16 rhs) +{ + return SfxGroupId((sal_uInt16)lhs + rhs); +} +#endif +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |