Click here to Skip to main content
15,878,959 members
Articles / Programming Languages / C

The Windows Access Control Model: Part 2

Rate me:
Please Sign up or sign in to vote.
4.80/5 (28 votes)
27 Jun 2005CPOL43 min read 244.2K   7.2K   113  
This second part of the Access Control series will program with the basic Access Control structures.
// preprocessed version of 'boost/mpl/vector_c.hpp' header
// see the original for copyright information

namespace boost {
namespace mpl {

namespace aux {
template< int N > struct vector_c_impl_chooser;
}

namespace aux {

template<>
struct vector_c_impl_chooser<0>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector0_c<
              T  
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<1>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector1_c<
              T, C0
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<2>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector2_c<
              T, C0, C1
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<3>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector3_c<
              T, C0, C1, C2
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<4>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector4_c<
              T, C0, C1, C2, C3
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<5>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector5_c<
              T, C0, C1, C2, C3, C4
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<6>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector6_c<
              T, C0, C1, C2, C3, C4, C5
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<7>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector7_c<
              T, C0, C1, C2, C3, C4, C5, C6
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<8>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector8_c<
              T, C0, C1, C2, C3, C4, C5, C6, C7
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<9>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector9_c<
              T, C0, C1, C2, C3, C4, C5, C6, C7, C8
            > type;
    };
};

} // namespace aux

namespace aux {

template<>
struct vector_c_impl_chooser<10>
{
    template<
          typename T
        , long C0, long C1, long C2, long C3, long C4, long C5, long C6
        , long C7, long C8, long C9
        >
    struct result_
    {
        typedef vector10_c<
              T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9
            > type;
    };
};

} // namespace aux

namespace aux {

template< long T >
struct is_vector_c_arg
{
    enum { value = true };
};

template<>
struct is_vector_c_arg<LONG_MAX>
{
    enum { value = false };
};

template<
      long T1, long T2, long T3, long T4, long T5, long T6, long T7, long T8
    , long T9, long T10
    >
struct vector_c_count_args
{
    enum { value =
          is_vector_c_arg<T1>::value + is_vector_c_arg<T2>::value 
        + is_vector_c_arg<T3>::value + is_vector_c_arg<T4>::value 
        + is_vector_c_arg<T5>::value + is_vector_c_arg<T6>::value 
        + is_vector_c_arg<T7>::value + is_vector_c_arg<T8>::value 
        + is_vector_c_arg<T9>::value + is_vector_c_arg<T10>::value
        };
};

template<
      typename T
    , long C0, long C1, long C2, long C3, long C4, long C5, long C6, long C7
    , long C8, long C9
    >
struct vector_c_impl
{
    typedef aux::vector_c_count_args< C0,C1,C2,C3,C4,C5,C6,C7,C8,C9 > arg_num_;
    typedef typename aux::vector_c_impl_chooser< arg_num_::value >
        ::template result_< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9 >::type type;
};

} // namespace aux

template<
      typename T
    , long C0 = LONG_MAX, long C1 = LONG_MAX, long C2 = LONG_MAX
    , long C3 = LONG_MAX, long C4 = LONG_MAX, long C5 = LONG_MAX
    , long C6 = LONG_MAX, long C7 = LONG_MAX, long C8 = LONG_MAX
    , long C9 = LONG_MAX
    >
struct vector_c
    : aux::vector_c_impl< T,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9 >::type
{
    typedef typename aux::vector_c_impl<
          T, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9
        >::type type;
};

} // namespace mpl
} // namespace boost

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Mr. Shah is a reclusive C++/C# developer lurking somewhere in the depths of the city of London. He learnt physics at Kings' College London and obtained a Master in Science there. Having earned an MCAD, he teeters on the brink of transitioning from C++ to C#, unsure of which language to jump to. Fortunately, he also knows how to use .NET interop to merge code between the two languages (which means he won't have to make the choice anytime soon).

His interests (apart from programming) are walking, football (the real one!), philosophy, history, retro-gaming, strategy gaming, and any good game in general.

He maintains a website / blog / FAQ / junk at shexec32.serveftp.net, where he places the best answers he's written to the questions you've asked. If you can find him, maybe you can hire Mr. Shah to help you with anything C++[/CLI]/C#/.NET related Smile | :) .

Comments and Discussions