<commit_before>//=======================================================================
// Copyright (c) 2014-2015 Baptiste Wicht
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#ifndef ETL_IMPL_CONVOLUTION_HPP
#define ETL_IMPL_CONVOLUTION_HPP

#include <algorithm>

//Include the implementations
#include "std/conv.hpp"
#include "sse/conv.hpp"
#include "avx/conv.hpp"
#include "reduc/conv_mmul.hpp"

namespace etl {

enum class conv_type {
    VALID,
    SAME,
    FULL
};

namespace detail {

template<typename I, typename K, typename C, typename Enable = void>
struct conv1_full_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv1_same_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv1_valid_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv2_full_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv2_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv2_same_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv2_valid_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv2_valid(input, kernel, conv);
    }
};

template<conv_type TT, typename I, typename K, typename C, typename Enable = void>
struct conv_deep_impl {
    template<conv_type TT2 = TT, typename I2 = I, cpp_enable_if(decay_traits<I2>::dimensions() == 3 && TT2 == conv_type::FULL)>
    static void apply(const I& input, const K& kernel, C&& conv){
        for(std::size_t i = 0; i < dim<0>(input); ++i){
            conv(i) = conv_2d_full(input(i), kernel(i));
        }
    }

    template<conv_type TT2 = TT, typename I2 = I, cpp_enable_if(decay_traits<I2>::dimensions() == 3 && TT2 == conv_type::SAME)>
    static void apply(const I& input, const K& kernel, C&& conv){
        for(std::size_t i = 0; i < dim<0>(input); ++i){
            conv(i) = conv_2d_same(input(i), kernel(i));
        }
    }

    template<conv_type TT2 = TT, typename I2 = I, cpp_enable_if(decay_traits<I2>::dimensions() == 3 && TT2 == conv_type::VALID)>
    static void apply(const I& input, const K& kernel, C&& conv){
        for(std::size_t i = 0; i < dim<0>(input); ++i){
            conv(i) = conv_2d_valid(input(i), kernel(i));
        }
    }

    template<typename I2 = I, cpp_enable_if((decay_traits<I2>::dimensions() > 3))>
    static void apply(const I& input, const K& kernel, C&& conv){
        for(std::size_t i = 0; i < dim<0>(input); ++i){
            conv_deep_impl<TT, decltype(input(i)), decltype(kernel(i)), decltype(conv(i))>::apply(input(i), kernel(i), conv(i));
        }
    }
};

template<typename I, typename K, typename C, typename Enable = void>
using conv_deep_valid_impl = conv_deep_impl<conv_type::VALID, I, K, C>;

template<typename I, typename K, typename C, typename Enable = void>
using conv_deep_same_impl = conv_deep_impl<conv_type::SAME, I, K, C>;

template<typename I, typename K, typename C, typename Enable = void>
using conv_deep_full_impl = conv_deep_impl<conv_type::FULL, I, K, C>;

template<typename A, typename B, typename C>
using is_vector_3s = cpp::and_c<all_single_precision<A, B, C>, all_dma<A, B, C>>;

template<typename A, typename B, typename C>
using is_vector_3d = cpp::and_c<all_double_precision<A, B, C>, all_dma<A, B, C>>;

template<typename A, typename B, typename C>
struct is_sse_dconv : cpp::and_u<vectorize_impl, vector_mode == vector_mode_t::SSE3, is_vector_3d<A, B, C>::value> {};

template<typename A, typename B, typename C>
struct is_sse_sconv : cpp::and_u<vectorize_impl, vector_mode == vector_mode_t::SSE3, is_vector_3s<A, B, C>::value> {};

template<typename A, typename B, typename C>
struct is_avx_dconv : cpp::and_u<vectorize_impl, vector_mode == vector_mode_t::AVX, is_vector_3d<A, B, C>::value> {};

template<typename A, typename B, typename C>
struct is_avx_sconv : cpp::and_u<vectorize_impl, vector_mode == vector_mode_t::AVX, is_vector_3s<A, B, C>::value> {};

template<typename I, typename K, typename C>
struct conv1_full_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_same_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_valid_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_full_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_same_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_valid_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::sconv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_full_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv2_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_same_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_valid_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv2_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_full_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::sconv2_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_same_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::sconv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_valid_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::sconv2_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_full_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_same_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_valid_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_full_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv2_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_same_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_valid_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv2_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_full_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_same_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_valid_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_valid_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv2_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_same_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_full_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv2_full(input, kernel, conv);
    }
};

} //end of namespace detail

} //end of namespace etl

#endif
<commit_msg>Limit the conv implementations for column major<commit_after>//=======================================================================
// Copyright (c) 2014-2015 Baptiste Wicht
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#ifndef ETL_IMPL_CONVOLUTION_HPP
#define ETL_IMPL_CONVOLUTION_HPP

#include <algorithm>

//Include the implementations
#include "std/conv.hpp"
#include "sse/conv.hpp"
#include "avx/conv.hpp"
#include "reduc/conv_mmul.hpp"

namespace etl {

enum class conv_type {
    VALID,
    SAME,
    FULL
};

namespace detail {

template<typename I, typename K, typename C, typename Enable = void>
struct conv1_full_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv1_same_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv1_valid_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv2_full_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv2_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv2_same_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C, typename Enable = void>
struct conv2_valid_impl {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::standard::conv2_valid(input, kernel, conv);
    }
};

template<conv_type TT, typename I, typename K, typename C, typename Enable = void>
struct conv_deep_impl {
    template<conv_type TT2 = TT, typename I2 = I, cpp_enable_if(decay_traits<I2>::dimensions() == 3 && TT2 == conv_type::FULL)>
    static void apply(const I& input, const K& kernel, C&& conv){
        for(std::size_t i = 0; i < dim<0>(input); ++i){
            conv(i) = conv_2d_full(input(i), kernel(i));
        }
    }

    template<conv_type TT2 = TT, typename I2 = I, cpp_enable_if(decay_traits<I2>::dimensions() == 3 && TT2 == conv_type::SAME)>
    static void apply(const I& input, const K& kernel, C&& conv){
        for(std::size_t i = 0; i < dim<0>(input); ++i){
            conv(i) = conv_2d_same(input(i), kernel(i));
        }
    }

    template<conv_type TT2 = TT, typename I2 = I, cpp_enable_if(decay_traits<I2>::dimensions() == 3 && TT2 == conv_type::VALID)>
    static void apply(const I& input, const K& kernel, C&& conv){
        for(std::size_t i = 0; i < dim<0>(input); ++i){
            conv(i) = conv_2d_valid(input(i), kernel(i));
        }
    }

    template<typename I2 = I, cpp_enable_if((decay_traits<I2>::dimensions() > 3))>
    static void apply(const I& input, const K& kernel, C&& conv){
        for(std::size_t i = 0; i < dim<0>(input); ++i){
            conv_deep_impl<TT, decltype(input(i)), decltype(kernel(i)), decltype(conv(i))>::apply(input(i), kernel(i), conv(i));
        }
    }
};

template<typename I, typename K, typename C, typename Enable = void>
using conv_deep_valid_impl = conv_deep_impl<conv_type::VALID, I, K, C>;

template<typename I, typename K, typename C, typename Enable = void>
using conv_deep_same_impl = conv_deep_impl<conv_type::SAME, I, K, C>;

template<typename I, typename K, typename C, typename Enable = void>
using conv_deep_full_impl = conv_deep_impl<conv_type::FULL, I, K, C>;

template<typename A, typename B, typename C>
using is_vector_3s = cpp::and_c<all_single_precision<A, B, C>, all_dma<A, B, C>>;

template<typename A, typename B, typename C>
using is_vector_3d = cpp::and_c<all_double_precision<A, B, C>, all_dma<A, B, C>>;

template<typename A, typename B, typename C>
struct is_sse_dconv : cpp::and_u<vectorize_impl, vector_mode == vector_mode_t::SSE3, is_vector_3d<A, B, C>::value, all_row_major<A,B,C>::value> {};

template<typename A, typename B, typename C>
struct is_sse_sconv : cpp::and_u<vectorize_impl, vector_mode == vector_mode_t::SSE3, is_vector_3s<A, B, C>::value, all_row_major<A,B,C>::value> {};

template<typename A, typename B, typename C>
struct is_avx_dconv : cpp::and_u<vectorize_impl, vector_mode == vector_mode_t::AVX, is_vector_3d<A, B, C>::value, all_row_major<A,B,C>::value> {};

template<typename A, typename B, typename C>
struct is_avx_sconv : cpp::and_u<vectorize_impl, vector_mode == vector_mode_t::AVX, is_vector_3s<A, B, C>::value, all_row_major<A,B,C>::value> {};

template<typename I, typename K, typename C>
struct conv1_full_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_same_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_valid_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_full_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_same_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_valid_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::sconv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_full_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv2_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_same_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_valid_impl<I, K, C, std::enable_if_t<is_avx_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::dconv2_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_full_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::sconv2_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_same_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::sconv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_valid_impl<I, K, C, std::enable_if_t<is_avx_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::avx::sconv2_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_full_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_same_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_valid_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_full_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv2_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_same_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_valid_impl<I, K, C, std::enable_if_t<is_sse_dconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::dconv2_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_full_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_full(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_same_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv1_valid_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv1_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_valid_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv2_valid(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_same_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv2_same(input, kernel, conv);
    }
};

template<typename I, typename K, typename C>
struct conv2_full_impl<I, K, C, std::enable_if_t<is_sse_sconv<I,K,C>::value>> {
    static void apply(const I& input, const K& kernel, C&& conv){
        impl::sse::sconv2_full(input, kernel, conv);
    }
};

} //end of namespace detail

} //end of namespace etl

#endif
<|endoftext|>


<commit_before>/*      _______   __   __   __   ______   __   __   _______   __   __
 *     / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___  /\ /  |\/ /\
 *    / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
 *   / / /__   / / // / // / // / /    / ___  / // ___  / // /| ' / /
 *  / /_// /\ / /_// / // / // /_/_   / / // / // /\_/ / // / |  / /
 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
 *
 * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessn and Per Larsson
 *
 *                                                         Js_./
 * Per Larsson a.k.a finalman                          _RqZ{a<^_aa
 * Olof Naessn a.k.a jansem/yakslem                _asww7!uY`>  )\a//
 *                                                 _Qhm`] _f "'c  1!5m
 * Visit: http://guichan.darkbits.org             )Qk<P ` _: :+' .'  "{[
 *                                               .)j(] .d_/ '-(  P .   S
 * License: (BSD)                                <Td/Z <fP"5(\"??"\a.  .L
 * Redistribution and use in source and          _dV>ws?a-?'      ._/L  #'
 * binary forms, with or without                 )4d[#7r, .   '     )d`)[
 * modification, are permitted provided         _Q-5'5W..j/?'   -?!\)cam'
 * that the following conditions are met:       j<<WP+k/);.        _W=j f
 * 1. Redistributions of source code must       .$%w\/]Q  . ."'  .  mj$
 *    retain the above copyright notice,        ]E.pYY(Q]>.   a     J@\
 *    this list of conditions and the           j(]1u<sE"L,. .   ./^ ]{a
 *    following disclaimer.                     4'_uomm\.  )L);-4     (3=
 * 2. Redistributions in binary form must        )_]X{Z('a_"a7'<a"a,  ]"[
 *    reproduce the above copyright notice,       #}<]m7`Za??4,P-"'7. ).m
 *    this list of conditions and the            ]d2e)Q(<Q(  ?94   b-  LQ/
 *    following disclaimer in the                <B!</]C)d_, '(<' .f. =C+m
 *    documentation and/or other materials      .Z!=J ]e []('-4f _ ) -.)m]'
 *    provided with the distribution.          .w[5]' _[ /.)_-"+?   _/ <W"
 * 3. Neither the name of Guichan nor the      :$we` _! + _/ .        j?
 *    names of its contributors may be used     =3)= _f  (_yQmWW$#(    "
 *    to endorse or promote products derived     -   W,  sQQQQmZQ#Wwa]..
 *    from this software without specific        (js, \[QQW$QWW#?!V"".
 *    prior written permission.                    ]y:.<\..          .
 *                                                 -]n w/ '         [.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT       )/ )/           !
 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY         <  (; sac    ,    '
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,               ]^ .-  %
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF            c <   r
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR            aga<  <La
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE          5%  )P'-3L
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR        _bQf` y`..)a
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,          ,J?4P'.P"_(\?d'.,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES               _Pa,)!f/<[]/  ?"
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT      _2-..:. .r+_,.. .
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,     ?a.<%"'  " -'.a_ _,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION)                     ^
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef GCN_EVENT_HPP
#define GCN_EVENT_HPP

#include "guichan/platform.hpp"

namespace gcn
{
    class Widget;

    /**
     * Base class for all events.
     *
     * @author Olof Naessn
     * @since 0.6.0
     */
    class GCN_CORE_DECLSPEC Event
    {
    public:

        /**
         * Constructor.
         *
         * @param source the source widget of the event.
         */
        Event(Widget* source);

        /**
         * Destructor.
         */
        virtual ~Event();

        /**
         * Gets the source widget of the event.
         *
         * @return the source widget of the event.
         */
        Widget* getSource() const;

    protected:
        Widget* mSource;
        unsigned int mType;
    };
}

#endif // end GCN_EVENT_HPP
<commit_msg>Unused type member variable has been removed. <commit_after>/*      _______   __   __   __   ______   __   __   _______   __   __
 *     / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___  /\ /  |\/ /\
 *    / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
 *   / / /__   / / // / // / // / /    / ___  / // ___  / // /| ' / /
 *  / /_// /\ / /_// / // / // /_/_   / / // / // /\_/ / // / |  / /
 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
 *
 * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessn and Per Larsson
 *
 *                                                         Js_./
 * Per Larsson a.k.a finalman                          _RqZ{a<^_aa
 * Olof Naessn a.k.a jansem/yakslem                _asww7!uY`>  )\a//
 *                                                 _Qhm`] _f "'c  1!5m
 * Visit: http://guichan.darkbits.org             )Qk<P ` _: :+' .'  "{[
 *                                               .)j(] .d_/ '-(  P .   S
 * License: (BSD)                                <Td/Z <fP"5(\"??"\a.  .L
 * Redistribution and use in source and          _dV>ws?a-?'      ._/L  #'
 * binary forms, with or without                 )4d[#7r, .   '     )d`)[
 * modification, are permitted provided         _Q-5'5W..j/?'   -?!\)cam'
 * that the following conditions are met:       j<<WP+k/);.        _W=j f
 * 1. Redistributions of source code must       .$%w\/]Q  . ."'  .  mj$
 *    retain the above copyright notice,        ]E.pYY(Q]>.   a     J@\
 *    this list of conditions and the           j(]1u<sE"L,. .   ./^ ]{a
 *    following disclaimer.                     4'_uomm\.  )L);-4     (3=
 * 2. Redistributions in binary form must        )_]X{Z('a_"a7'<a"a,  ]"[
 *    reproduce the above copyright notice,       #}<]m7`Za??4,P-"'7. ).m
 *    this list of conditions and the            ]d2e)Q(<Q(  ?94   b-  LQ/
 *    following disclaimer in the                <B!</]C)d_, '(<' .f. =C+m
 *    documentation and/or other materials      .Z!=J ]e []('-4f _ ) -.)m]'
 *    provided with the distribution.          .w[5]' _[ /.)_-"+?   _/ <W"
 * 3. Neither the name of Guichan nor the      :$we` _! + _/ .        j?
 *    names of its contributors may be used     =3)= _f  (_yQmWW$#(    "
 *    to endorse or promote products derived     -   W,  sQQQQmZQ#Wwa]..
 *    from this software without specific        (js, \[QQW$QWW#?!V"".
 *    prior written permission.                    ]y:.<\..          .
 *                                                 -]n w/ '         [.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT       )/ )/           !
 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY         <  (; sac    ,    '
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,               ]^ .-  %
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF            c <   r
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR            aga<  <La
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE          5%  )P'-3L
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR        _bQf` y`..)a
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,          ,J?4P'.P"_(\?d'.,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES               _Pa,)!f/<[]/  ?"
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT      _2-..:. .r+_,.. .
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,     ?a.<%"'  " -'.a_ _,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION)                     ^
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef GCN_EVENT_HPP
#define GCN_EVENT_HPP

#include "guichan/platform.hpp"

namespace gcn
{
    class Widget;

    /**
     * Base class for all events.
     *
     * @author Olof Naessn
     * @since 0.6.0
     */
    class GCN_CORE_DECLSPEC Event
    {
    public:

        /**
         * Constructor.
         *
         * @param source the source widget of the event.
         */
        Event(Widget* source);

        /**
         * Destructor.
         */
        virtual ~Event();

        /**
         * Gets the source widget of the event.
         *
         * @return the source widget of the event.
         */
        Widget* getSource() const;

    protected:
        Widget* mSource;
    };
}

#endif // end GCN_EVENT_HPP
<|endoftext|>


<commit_before> /*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: NColumns.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: kz $ $Date: 2006-02-28 10:33:06 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 *    Contributor(s): Jayant Madavi_______________________________________
 *
 *
 ************************************************************************/

#ifndef _CONNECTIVITY_EVOAB_COLUMNS_HXX_
#define _CONNECTIVITY_EVOAB_COLUMNS_HXX_

#ifndef _CONNECTIVITY_EVOAB_TABLE_HXX_
#include "NTable.hxx"
#endif

#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_
#include "connectivity/sdbcx/VCollection.hxx"
#endif

namespace connectivity
{
    namespace evoab
    {
        class OEvoabColumns : public sdbcx::OCollection
        {
        protected:
            OEvoabTable*    m_pTable;

            virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
            virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);

        public:
            OEvoabColumns(  OEvoabTable* _pTable,
                        ::osl::Mutex& _rMutex,
                        const TStringVector &_rVector
                        ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector),
                            m_pTable(_pTable)
            { }
        };
    }
}

#endif // _CONNECTIVITY_EVOAB_COLUMNS_HXX_
<commit_msg>INTEGRATION: CWS changefileheader (1.2.314); FILE MERGED 2008/04/01 10:52:56 thb 1.2.314.2: #i85898# Stripping all external header guards 2008/03/28 15:23:32 rt 1.2.314.1: #i87441# Change license header to LPGL v3.<commit_after> /*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: NColumns.hxx,v $
 * $Revision: 1.3 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _CONNECTIVITY_EVOAB_COLUMNS_HXX_
#define _CONNECTIVITY_EVOAB_COLUMNS_HXX_

#include "NTable.hxx"
#include "connectivity/sdbcx/VCollection.hxx"

namespace connectivity
{
    namespace evoab
    {
        class OEvoabColumns : public sdbcx::OCollection
        {
        protected:
            OEvoabTable*    m_pTable;

            virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
            virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);

        public:
            OEvoabColumns(  OEvoabTable* _pTable,
                        ::osl::Mutex& _rMutex,
                        const TStringVector &_rVector
                        ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector),
                            m_pTable(_pTable)
            { }
        };
    }
}

#endif // _CONNECTIVITY_EVOAB_COLUMNS_HXX_
<|endoftext|>


<commit_before>#ifndef LIBPORT_EXPORT_HH
# define LIBPORT_EXPORT_HH

# include <libport/detect-win32.h>

# ifdef BUILDING_LIBPORT
#  ifdef WIN32
#   define LIBPORT_API __declspec(dllexport)
#  else
#    define LIBPORT_API __attribute__((visibility("default")))
#  endif
# endif

# ifndef LIBPORT_API
#  ifdef WIN32
#   define LIBPORT_API __declspec(dllimport)
#  else
#   define LIBPORT_API
#  endif
# endif

#endif
<commit_msg>For exceptions to work, GCC must see the right visibility at all times.<commit_after>#ifndef LIBPORT_EXPORT_HH
# define LIBPORT_EXPORT_HH

# include <libport/detect-win32.h>

# ifdef WIN32
#  ifdef BUILDING_LIBPORT
#   define LIBPORT_API __declspec(dllexport)
#  else
#   define LIBPORT_API __declspec(dllimport)
#  endif
# else
#  define LIBPORT_API __attribute__((visibility("default")))
# endif

#endif // LIBPORT_EXPORT_HH
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: dbcharset.cxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: fs $ $Date: 2001-04-09 06:09:58 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library 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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _DBHELPER_DBCHARSET_HXX_
#include <connectivity/dbcharset.hxx>
#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif

//.........................................................................
namespace dbtools
{
//.........................................................................

    //-------------------------------------------------------------------------
    template <class TYPE>
    sal_Int32 getSequenceIndex( const ::std::vector< TYPE >& _rUnsortedContainer, const TYPE& _rLookupElement )
    {
        for (   ::std::vector< TYPE >::const_iterator aSearch = _rUnsortedContainer.begin();
                aSearch != _rUnsortedContainer.end();
                ++aSearch
            )
            if (*aSearch == _rLookupElement)
                return aSearch - _rUnsortedContainer.begin();

        return _rUnsortedContainer.size();
    }

    //=========================================================================
    //= OCharsetMap
    //=========================================================================
    //-------------------------------------------------------------------------
    OCharsetMap::OCharsetMap()
    #ifdef _DEBUG
        :m_nLivingIterators(0)
    #endif
    {
        m_aEncodings.resize(9);
        m_aEncodings[0] = RTL_TEXTENCODING_MS_1252;     // ANSI
        m_aEncodings[1] = RTL_TEXTENCODING_APPLE_ROMAN; // MAC
        m_aEncodings[2] = RTL_TEXTENCODING_IBM_437;     // IBMPC_437
        m_aEncodings[3] = RTL_TEXTENCODING_IBM_850;     // IBMPC_850
        m_aEncodings[4] = RTL_TEXTENCODING_IBM_860;     // IBMPC_860
        m_aEncodings[5] = RTL_TEXTENCODING_IBM_861;     // IBMPC_861
        m_aEncodings[6] = RTL_TEXTENCODING_IBM_863;     // IBMPC_863
        m_aEncodings[7] = RTL_TEXTENCODING_IBM_865;     // IBMPC_865
        m_aEncodings[8] = RTL_TEXTENCODING_DONTKNOW;    // SYSTEM

        m_aNames.resize(9);
        m_aNames[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ANSI"));
        m_aNames[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAC"));
        m_aNames[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_437"));
        m_aNames[3] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_850"));
        m_aNames[4] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_860"));
        m_aNames[5] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_861"));
        m_aNames[6] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_863"));
        m_aNames[7] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_865"));
        m_aNames[8] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSTEM"));

        OSL_ENSURE(m_aEncodings.size() == m_aNames.size(),
            "OCharsetMap::OCharsetMap: inconsistentce(1)!");

        // the IANA representations of the character sets which we know
        m_aIanaNames.resize(9);
        m_aIanaNames[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("windows-1252"));
        m_aIanaNames[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macintosh"));
        m_aIanaNames[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM437"));
        m_aIanaNames[3] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM850"));
        m_aIanaNames[4] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM860"));
        m_aIanaNames[5] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM861"));
        m_aIanaNames[6] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM863"));
        m_aIanaNames[7] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM865"));
        m_aIanaNames[8] = ::rtl::OUString();

        OSL_ENSURE(m_aNames.size() == m_aIanaNames.size(),
            "OCharsetMap::OCharsetMap: inconsistentce(2)!");
    }

    //-------------------------------------------------------------------------
    OCharsetMap::~OCharsetMap()
    {
        OSL_ENSURE(0 == m_nLivingIterators, "OCharsetMap::~OCharsetMap : there are still living iterator objects!");
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator OCharsetMap::begin() const
    {
        return CharsetIterator(this, 0);
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator    OCharsetMap::find(const rtl_TextEncoding _eEncoding) const
    {
        return CharsetIterator(this, getSequenceIndex(m_aEncodings, _eEncoding));
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator    OCharsetMap::find(const ::rtl::OUString& _rIanaName, const IANA&) const
    {
        return CharsetIterator(this, getSequenceIndex(m_aIanaNames, _rIanaName));
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator    OCharsetMap::find(const ::rtl::OUString& _rLogicalName, const Logical&) const
    {
        return CharsetIterator(this, getSequenceIndex(m_aNames, _rLogicalName));
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator OCharsetMap::end() const
    {
        return CharsetIterator(this, m_aNames.size());
    }

    //=========================================================================
    //= CharsetIteratorDerefHelper
    //=========================================================================
    //-------------------------------------------------------------------------
    CharsetIteratorDerefHelper::CharsetIteratorDerefHelper(const CharsetIteratorDerefHelper& _rSource)
        :m_eEncoding(_rSource.m_eEncoding)
        ,m_aIanaName(_rSource.m_aIanaName)
        ,m_aName(_rSource.m_aName)
    {
    }

    //-------------------------------------------------------------------------
    CharsetIteratorDerefHelper::CharsetIteratorDerefHelper(const rtl_TextEncoding _eEncoding, const ::rtl::OUString& _rIanaName, const ::rtl::OUString& _rName)
        :m_eEncoding(_eEncoding)
        ,m_aIanaName(_rIanaName)
        ,m_aName(_rName)
    {
    }

    //-------------------------------------------------------------------------
    CharsetIteratorDerefHelper::CharsetIteratorDerefHelper()
        :m_eEncoding(RTL_TEXTENCODING_DONTKNOW)
    {
    }

    //=========================================================================
    //= OCharsetMap::CharsetIterator
    //=========================================================================
    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator::CharsetIterator(const OCharsetMap* _pContainer, sal_Int32 _nInitialPos)
        :m_pContainer(_pContainer)
        ,m_nPosition(_nInitialPos)
    {
        OSL_ENSURE(m_pContainer, "OCharsetMap::CharsetIterator::CharsetIterator : invalid container!");
    #ifdef _DEBUG
        ++const_cast<OCharsetMap*>(m_pContainer)->m_nLivingIterators;
    #endif
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator::CharsetIterator(const CharsetIterator& _rSource)
        :m_pContainer(_rSource.m_pContainer)
        ,m_nPosition(_rSource.m_nPosition)
    {
    #ifdef _DEBUG
        ++const_cast<OCharsetMap*>(m_pContainer)->m_nLivingIterators;
    #endif
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator::~CharsetIterator()
    {
    #ifdef _DEBUG
        --const_cast<OCharsetMap*>(m_pContainer)->m_nLivingIterators;
    #endif
    }

    //-------------------------------------------------------------------------
    CharsetIteratorDerefHelper OCharsetMap::CharsetIterator::operator*() const
    {
        OSL_ENSURE(m_nPosition < m_pContainer->m_aEncodings.size(), "OCharsetMap::CharsetIterator::operator*: invalid position!");
        OSL_ENSURE(m_nPosition < m_pContainer->m_aIanaNames.size(), "OCharsetMap::CharsetIterator::operator*: invalid position!");
        OSL_ENSURE(m_nPosition < m_pContainer->m_aNames.size(), "OCharsetMap::CharsetIterator::operator*: invalid position!");
        return CharsetIteratorDerefHelper(
            m_pContainer->m_aEncodings[m_nPosition],
            m_pContainer->m_aIanaNames[m_nPosition],
            m_pContainer->m_aNames[m_nPosition]);
    }

    //-------------------------------------------------------------------------
    const OCharsetMap::CharsetIterator& OCharsetMap::CharsetIterator::operator++()
    {
        OSL_ENSURE(m_nPosition < m_pContainer->m_aNames.size(), "OCharsetMap::CharsetIterator::operator++ : invalid position!");
        if (m_nPosition < m_pContainer->m_aNames.size())
            ++m_nPosition;
        return *this;
    }

    //-------------------------------------------------------------------------
    const OCharsetMap::CharsetIterator& OCharsetMap::CharsetIterator::operator--()
    {
        OSL_ENSURE(m_nPosition >= 0, "OCharsetMap::CharsetIterator::operator-- : invalid position!");
        if (m_nPosition >= 0)
            --m_nPosition;
        return *this;
    }

    //-------------------------------------------------------------------------
    sal_Int32 operator-(const OCharsetMap::CharsetIterator& lhs, const OCharsetMap::CharsetIterator& rhs)
    {
        return lhs.m_nPosition - rhs.m_nPosition;
    }

    //-------------------------------------------------------------------------
    bool operator==(const OCharsetMap::CharsetIterator& lhs, const OCharsetMap::CharsetIterator& rhs)
    {
        return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_nPosition == rhs.m_nPosition);
    }

//.........................................................................
}   // namespace dbtools
//.........................................................................

/*************************************************************************
 * history:
 *  $Log: not supported by cvs2svn $
 *  Revision 1.2  2001/02/13 09:47:39  fs
 *  #83632# merge IBMPC, IBMPC(850), DOS
 *
 *  Revision 1.1  2000/11/29 22:21:42  fs
 *  initial checkin - helper class for translating charset representations
 *
 *
 *  Revision 1.0 29.11.00 18:42:55  fs
 ************************************************************************/

<commit_msg>#86370# add UTF-8 to the list of supported charsets<commit_after>/*************************************************************************
 *
 *  $RCSfile: dbcharset.cxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: fs $ $Date: 2001-04-27 08:04:07 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library 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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _DBHELPER_DBCHARSET_HXX_
#include <connectivity/dbcharset.hxx>
#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif

//.........................................................................
namespace dbtools
{
//.........................................................................

    //-------------------------------------------------------------------------
    template <class TYPE>
    sal_Int32 getSequenceIndex( const ::std::vector< TYPE >& _rUnsortedContainer, const TYPE& _rLookupElement )
    {
        for (   ::std::vector< TYPE >::const_iterator aSearch = _rUnsortedContainer.begin();
                aSearch != _rUnsortedContainer.end();
                ++aSearch
            )
            if (*aSearch == _rLookupElement)
                return aSearch - _rUnsortedContainer.begin();

        return _rUnsortedContainer.size();
    }

    //=========================================================================
    //= OCharsetMap
    //=========================================================================
    //-------------------------------------------------------------------------
    OCharsetMap::OCharsetMap()
    #ifdef _DEBUG
        :m_nLivingIterators(0)
    #endif
    {
        m_aEncodings.resize(10);
        m_aEncodings[0] = RTL_TEXTENCODING_MS_1252;     // ANSI
        m_aEncodings[1] = RTL_TEXTENCODING_APPLE_ROMAN; // MAC
        m_aEncodings[2] = RTL_TEXTENCODING_IBM_437;     // IBMPC_437
        m_aEncodings[3] = RTL_TEXTENCODING_IBM_850;     // IBMPC_850
        m_aEncodings[4] = RTL_TEXTENCODING_IBM_860;     // IBMPC_860
        m_aEncodings[5] = RTL_TEXTENCODING_IBM_861;     // IBMPC_861
        m_aEncodings[6] = RTL_TEXTENCODING_IBM_863;     // IBMPC_863
        m_aEncodings[7] = RTL_TEXTENCODING_IBM_865;     // IBMPC_865
        m_aEncodings[8] = RTL_TEXTENCODING_DONTKNOW;    // SYSTEM
        m_aEncodings[9] = RTL_TEXTENCODING_UTF8;        // UTF-8

        m_aNames.resize(10);
        m_aNames[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ANSI"));
        m_aNames[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAC"));
        m_aNames[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_437"));
        m_aNames[3] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_850"));
        m_aNames[4] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_860"));
        m_aNames[5] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_861"));
        m_aNames[6] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_863"));
        m_aNames[7] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_865"));
        m_aNames[8] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSTEM"));
        m_aNames[9] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UTF-8"));

        OSL_ENSURE(m_aEncodings.size() == m_aNames.size(),
            "OCharsetMap::OCharsetMap: inconsistentce(1)!");

        // the IANA representations of the character sets which we know
        m_aIanaNames.resize(10);
        m_aIanaNames[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("windows-1252"));
        m_aIanaNames[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macintosh"));
        m_aIanaNames[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM437"));
        m_aIanaNames[3] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM850"));
        m_aIanaNames[4] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM860"));
        m_aIanaNames[5] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM861"));
        m_aIanaNames[6] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM863"));
        m_aIanaNames[7] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM865"));
        m_aIanaNames[8] = ::rtl::OUString();
        m_aIanaNames[9] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UTF-8"));

        OSL_ENSURE(m_aNames.size() == m_aIanaNames.size(),
            "OCharsetMap::OCharsetMap: inconsistentce(2)!");
    }

    //-------------------------------------------------------------------------
    OCharsetMap::~OCharsetMap()
    {
        OSL_ENSURE(0 == m_nLivingIterators, "OCharsetMap::~OCharsetMap : there are still living iterator objects!");
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator OCharsetMap::begin() const
    {
        return CharsetIterator(this, 0);
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator    OCharsetMap::find(const rtl_TextEncoding _eEncoding) const
    {
        return CharsetIterator(this, getSequenceIndex(m_aEncodings, _eEncoding));
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator    OCharsetMap::find(const ::rtl::OUString& _rIanaName, const IANA&) const
    {
        return CharsetIterator(this, getSequenceIndex(m_aIanaNames, _rIanaName));
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator    OCharsetMap::find(const ::rtl::OUString& _rLogicalName, const Logical&) const
    {
        return CharsetIterator(this, getSequenceIndex(m_aNames, _rLogicalName));
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator OCharsetMap::end() const
    {
        return CharsetIterator(this, m_aNames.size());
    }

    //=========================================================================
    //= CharsetIteratorDerefHelper
    //=========================================================================
    //-------------------------------------------------------------------------
    CharsetIteratorDerefHelper::CharsetIteratorDerefHelper(const CharsetIteratorDerefHelper& _rSource)
        :m_eEncoding(_rSource.m_eEncoding)
        ,m_aIanaName(_rSource.m_aIanaName)
        ,m_aName(_rSource.m_aName)
    {
    }

    //-------------------------------------------------------------------------
    CharsetIteratorDerefHelper::CharsetIteratorDerefHelper(const rtl_TextEncoding _eEncoding, const ::rtl::OUString& _rIanaName, const ::rtl::OUString& _rName)
        :m_eEncoding(_eEncoding)
        ,m_aIanaName(_rIanaName)
        ,m_aName(_rName)
    {
    }

    //-------------------------------------------------------------------------
    CharsetIteratorDerefHelper::CharsetIteratorDerefHelper()
        :m_eEncoding(RTL_TEXTENCODING_DONTKNOW)
    {
    }

    //=========================================================================
    //= OCharsetMap::CharsetIterator
    //=========================================================================
    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator::CharsetIterator(const OCharsetMap* _pContainer, sal_Int32 _nInitialPos)
        :m_pContainer(_pContainer)
        ,m_nPosition(_nInitialPos)
    {
        OSL_ENSURE(m_pContainer, "OCharsetMap::CharsetIterator::CharsetIterator : invalid container!");
    #ifdef _DEBUG
        ++const_cast<OCharsetMap*>(m_pContainer)->m_nLivingIterators;
    #endif
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator::CharsetIterator(const CharsetIterator& _rSource)
        :m_pContainer(_rSource.m_pContainer)
        ,m_nPosition(_rSource.m_nPosition)
    {
    #ifdef _DEBUG
        ++const_cast<OCharsetMap*>(m_pContainer)->m_nLivingIterators;
    #endif
    }

    //-------------------------------------------------------------------------
    OCharsetMap::CharsetIterator::~CharsetIterator()
    {
    #ifdef _DEBUG
        --const_cast<OCharsetMap*>(m_pContainer)->m_nLivingIterators;
    #endif
    }

    //-------------------------------------------------------------------------
    CharsetIteratorDerefHelper OCharsetMap::CharsetIterator::operator*() const
    {
        OSL_ENSURE((sal_uInt32)m_nPosition < m_pContainer->m_aEncodings.size(), "OCharsetMap::CharsetIterator::operator*: invalid position!");
        OSL_ENSURE((sal_uInt32)m_nPosition < m_pContainer->m_aIanaNames.size(), "OCharsetMap::CharsetIterator::operator*: invalid position!");
        OSL_ENSURE((sal_uInt32)m_nPosition < m_pContainer->m_aNames.size(), "OCharsetMap::CharsetIterator::operator*: invalid position!");
        return CharsetIteratorDerefHelper(
            m_pContainer->m_aEncodings[m_nPosition],
            m_pContainer->m_aIanaNames[m_nPosition],
            m_pContainer->m_aNames[m_nPosition]);
    }

    //-------------------------------------------------------------------------
    const OCharsetMap::CharsetIterator& OCharsetMap::CharsetIterator::operator++()
    {
        OSL_ENSURE((sal_uInt32)m_nPosition < m_pContainer->m_aNames.size(), "OCharsetMap::CharsetIterator::operator++ : invalid position!");
        if ((sal_uInt32)m_nPosition < m_pContainer->m_aNames.size())
            ++m_nPosition;
        return *this;
    }

    //-------------------------------------------------------------------------
    const OCharsetMap::CharsetIterator& OCharsetMap::CharsetIterator::operator--()
    {
        OSL_ENSURE(m_nPosition >= 0, "OCharsetMap::CharsetIterator::operator-- : invalid position!");
        if (m_nPosition >= 0)
            --m_nPosition;
        return *this;
    }

    //-------------------------------------------------------------------------
    sal_Int32 operator-(const OCharsetMap::CharsetIterator& lhs, const OCharsetMap::CharsetIterator& rhs)
    {
        return lhs.m_nPosition - rhs.m_nPosition;
    }

    //-------------------------------------------------------------------------
    bool operator==(const OCharsetMap::CharsetIterator& lhs, const OCharsetMap::CharsetIterator& rhs)
    {
        return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_nPosition == rhs.m_nPosition);
    }

//.........................................................................
}   // namespace dbtools
//.........................................................................

/*************************************************************************
 * history:
 *  $Log: not supported by cvs2svn $
 *  Revision 1.3  2001/04/09 06:09:58  fs
 *  m_nLivingIterators for _DEBUG, not DBG_UTIL
 *
 *  Revision 1.2  2001/02/13 09:47:39  fs
 *  #83632# merge IBMPC, IBMPC(850), DOS
 *
 *  Revision 1.1  2000/11/29 22:21:42  fs
 *  initial checkin - helper class for translating charset representations
 *
 *
 *  Revision 1.0 29.11.00 18:42:55  fs
 ************************************************************************/

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: parsenode_s.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: kz $ $Date: 2006-12-13 16:26:45 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef CONNECTIVITY_PARSENODE_SIMPLE_HXX
#define CONNECTIVITY_PARSENODE_SIMPLE_HXX

#ifndef CONNECTIVITY_VIRTUAL_DBTOOLS_HXX
#include <connectivity/virtualdbtools.hxx>
#endif
#ifndef CONNECTIVITY_DBTOOLS_REFBASE_HXX
#include "refbase.hxx"
#endif

//........................................................................
namespace connectivity
{
//........................................................................

    class OSQLParseNode;
    //================================================================
    //= OSimpleParseNode
    //================================================================
    class OSimpleParseNode
            :public simple::ISQLParseNode
            ,public ORefBase
    {
    protected:
        const OSQLParseNode*    m_pFullNode;
        sal_Bool                m_bOwner;

    public:
        OSimpleParseNode(const OSQLParseNode* _pNode, sal_Bool _bTakeOwnership = sal_True);
        ~OSimpleParseNode();

        // ISQLParseNode
        virtual void parseNodeToStr(::rtl::OUString& _rString,
            const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
            const IParseContext* _pContext
        ) const;

        virtual void parseNodeToPredicateStr(::rtl::OUString& _rString,
            const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
            const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
            const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
            const ::com::sun::star::lang::Locale& _rIntl,
            const sal_Char _cDecSeparator,
            const IParseContext* _pContext
        ) const;

        // disambiguate IReference
        virtual oslInterlockedCount SAL_CALL acquire();
        virtual oslInterlockedCount SAL_CALL release();
    };

//........................................................................
}   // namespace connectivity
//........................................................................

#endif // CONNECTIVITY_PARSENODE_SIMPLE_HXX

<commit_msg>INTEGRATION: CWS changefileheader (1.5.180); FILE MERGED 2008/04/01 10:53:48 thb 1.5.180.2: #i85898# Stripping all external header guards 2008/03/28 15:24:41 rt 1.5.180.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: parsenode_s.hxx,v $
 * $Revision: 1.6 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef CONNECTIVITY_PARSENODE_SIMPLE_HXX
#define CONNECTIVITY_PARSENODE_SIMPLE_HXX

#include <connectivity/virtualdbtools.hxx>
#include "refbase.hxx"

//........................................................................
namespace connectivity
{
//........................................................................

    class OSQLParseNode;
    //================================================================
    //= OSimpleParseNode
    //================================================================
    class OSimpleParseNode
            :public simple::ISQLParseNode
            ,public ORefBase
    {
    protected:
        const OSQLParseNode*    m_pFullNode;
        sal_Bool                m_bOwner;

    public:
        OSimpleParseNode(const OSQLParseNode* _pNode, sal_Bool _bTakeOwnership = sal_True);
        ~OSimpleParseNode();

        // ISQLParseNode
        virtual void parseNodeToStr(::rtl::OUString& _rString,
            const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
            const IParseContext* _pContext
        ) const;

        virtual void parseNodeToPredicateStr(::rtl::OUString& _rString,
            const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
            const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
            const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
            const ::com::sun::star::lang::Locale& _rIntl,
            const sal_Char _cDecSeparator,
            const IParseContext* _pContext
        ) const;

        // disambiguate IReference
        virtual oslInterlockedCount SAL_CALL acquire();
        virtual oslInterlockedCount SAL_CALL release();
    };

//........................................................................
}   // namespace connectivity
//........................................................................

#endif // CONNECTIVITY_PARSENODE_SIMPLE_HXX

<|endoftext|>


<commit_before>/*****************************************************************************
 *
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2006 Artem Pavlenko
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *****************************************************************************/

//$Id: ctrans.hpp 39 2005-04-10 20:39:53Z pavlenko $

#ifndef CTRANS_HPP
#define CTRANS_HPP

#include <algorithm>

#include <mapnik/box2d.hpp>
#include <mapnik/coord_array.hpp>
#include <mapnik/proj_transform.hpp>

namespace mapnik {
   typedef coord_array<coord2d> CoordinateArray;

   template <typename Transform,typename Geometry>
   struct MAPNIK_DECL coord_transform
   {
      coord_transform(Transform const& t, Geometry& geom)
         : t_(t), geom_(geom) {}

      unsigned  vertex(double *x , double *y) const
      {
         unsigned command = geom_.vertex(x,y);
         t_.forward(x,y);
         return command;
      }

      void rewind (unsigned pos)
      {
         geom_.rewind(pos);
      }

     private:
      Transform const& t_;
      Geometry& geom_;
   };

   template <typename Transform,typename Geometry>
   struct MAPNIK_DECL coord_transform2
   {
      coord_transform2(Transform const& t,
                       Geometry const& geom,
                       proj_transform const& prj_trans)
         : t_(t),
         geom_(geom),
         prj_trans_(prj_trans)  {}

      unsigned  vertex(double * x , double  * y) const
      {
         unsigned command = geom_.vertex(x,y);
         double z=0;
         prj_trans_.backward(*x,*y,z);
         t_.forward(x,y);
         return command;
      }

      void rewind (unsigned pos)
      {
         geom_.rewind(pos);
      }

     private:
      Transform const& t_;
      Geometry const& geom_;
      proj_transform const& prj_trans_;
   };

   template <typename Transform,typename Geometry>
   struct MAPNIK_DECL coord_transform3
   {
      coord_transform3(Transform const& t,
                       Geometry const& geom,
                       proj_transform const& prj_trans,
                       int dx, int dy)
         : t_(t),
         geom_(geom),
         prj_trans_(prj_trans),
         dx_(dx), dy_(dy) {}

      unsigned  vertex(double * x , double  * y) const
      {
         unsigned command = geom_.vertex(x,y);
         double z=0;
         prj_trans_.backward(*x,*y,z);
         t_.forward(x,y);
         *x+=dx_;
         *y+=dy_;
         return command;
      }

      void rewind (unsigned pos)
      {
         geom_.rewind(pos);
      }

     private:
      Transform const& t_;
      Geometry const& geom_;
      proj_transform const& prj_trans_;
      int dx_;
      int dy_;
   };

   class CoordTransform
   {
      private:
         int width_;
         int height_;
         double sx_;
         double sy_;
         box2d<double> extent_;
         double offset_x_;
         double offset_y_;
      public:
         CoordTransform(int width,int height,const box2d<double>& extent,
                        double offset_x = 0, double offset_y = 0)
            :width_(width),height_(height),extent_(extent),offset_x_(offset_x),offset_y_(offset_y)
         {
            sx_ = ((double)width_)/extent_.width();
            sy_ = ((double)height_)/extent_.height();
         }

         inline int width() const
         {
            return width_;
         }

         inline int height() const
         {
            return height_;
         }

         inline double scale_x() const
         {
            return sx_;
         }

         inline double scale_y() const
         {
            return sy_;
         }

         inline void forward(double * x, double * y) const
         {
            *x = (*x - extent_.minx()) * sx_ - offset_x_;
            *y = (extent_.maxy() - *y) * sy_ - offset_y_;
         }

         inline void backward(double * x, double * y) const
         {
            *x = extent_.minx() + (*x + offset_x_)/sx_;
            *y = extent_.maxy() - (*y + offset_y_)/sy_;
         }

         inline coord2d& forward(coord2d& c) const
         {
            forward(&c.x,&c.y);
            return c;
         }

         inline coord2d& backward(coord2d& c) const
         {
            backward(&c.x,&c.y);
            return c;
         }

         inline box2d<double> forward(const box2d<double>& e) const
         {
            double x0 = e.minx();
            double y0 = e.miny();
            double x1 = e.maxx();
            double y1 = e.maxy();
            forward(&x0,&y0);
            forward(&x1,&y1);
            return box2d<double>(x0,y0,x1,y1);
         }

         inline box2d<double> backward(const box2d<double>& e) const
         {
            double x0 = e.minx();
            double y0 = e.miny();
            double x1 = e.maxx();
            double y1 = e.maxy();
            backward(&x0,&y0);
            backward(&x1,&y1);
            return box2d<double>(x0,y0,x1,y1);
         }

         inline CoordinateArray& forward(CoordinateArray& coords) const
         {
            for (unsigned i=0;i<coords.size();++i)
            {
               forward(coords[i]);
            }
            return coords;
         }

         inline CoordinateArray& backward(CoordinateArray& coords) const
         {
            for (unsigned i=0;i<coords.size();++i)
            {
               backward(coords[i]);
            }
            return coords;
         }
         inline box2d<double> const& extent() const
         {
            return extent_;
         }
   };
}

#endif //CTRANS_HPP
<commit_msg>+ don't use C style casts<commit_after>/*****************************************************************************
 *
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2006 Artem Pavlenko
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *****************************************************************************/

//$Id: ctrans.hpp 39 2005-04-10 20:39:53Z pavlenko $

#ifndef CTRANS_HPP
#define CTRANS_HPP

#include <algorithm>

#include <mapnik/box2d.hpp>
#include <mapnik/coord_array.hpp>
#include <mapnik/proj_transform.hpp>

namespace mapnik {
typedef coord_array<coord2d> CoordinateArray;

template <typename Transform,typename Geometry>
struct MAPNIK_DECL coord_transform
{
    coord_transform(Transform const& t, Geometry& geom)
	: t_(t), geom_(geom) {}

    unsigned  vertex(double *x , double *y) const
    {
	unsigned command = geom_.vertex(x,y);
	t_.forward(x,y);
	return command;
    }

    void rewind (unsigned pos)
    {
	geom_.rewind(pos);
    }

private:
    Transform const& t_;
    Geometry& geom_;
};

template <typename Transform,typename Geometry>
struct MAPNIK_DECL coord_transform2
{
    coord_transform2(Transform const& t,
		     Geometry const& geom,
		     proj_transform const& prj_trans)
	: t_(t),
	geom_(geom),
	prj_trans_(prj_trans)  {}

    unsigned  vertex(double * x , double  * y) const
    {
	unsigned command = geom_.vertex(x,y);
	double z=0;
	prj_trans_.backward(*x,*y,z);
	t_.forward(x,y);
	return command;
    }

    void rewind (unsigned pos)
    {
	geom_.rewind(pos);
    }

private:
    Transform const& t_;
    Geometry const& geom_;
    proj_transform const& prj_trans_;
};

template <typename Transform,typename Geometry>
struct MAPNIK_DECL coord_transform3
{
    coord_transform3(Transform const& t,
		     Geometry const& geom,
		     proj_transform const& prj_trans,
		     int dx, int dy)
	: t_(t),
	geom_(geom),
	prj_trans_(prj_trans),
	dx_(dx), dy_(dy) {}

    unsigned  vertex(double * x , double  * y) const
    {
	unsigned command = geom_.vertex(x,y);
	double z=0;
	prj_trans_.backward(*x,*y,z);
	t_.forward(x,y);
	*x+=dx_;
	*y+=dy_;
	return command;
    }

    void rewind (unsigned pos)
    {
	geom_.rewind(pos);
    }

private:
    Transform const& t_;
    Geometry const& geom_;
    proj_transform const& prj_trans_;
    int dx_;
    int dy_;
};

class CoordTransform
{
private:
    int width_;
    int height_;
    double sx_;
    double sy_;
    box2d<double> extent_;
    double offset_x_;
    double offset_y_;
public:
    CoordTransform(int width,int height,const box2d<double>& extent,
		   double offset_x = 0, double offset_y = 0)
	:width_(width),height_(height),extent_(extent),offset_x_(offset_x),offset_y_(offset_y)
    {
	sx_ = (double(width_))/extent_.width();
	sy_ = (double(height_))/extent_.height();
    }

    inline int width() const
    {
	return width_;
    }

    inline int height() const
    {
	return height_;
    }

    inline double scale_x() const
    {
	return sx_;
    }

    inline double scale_y() const
    {
	return sy_;
    }

    inline void forward(double * x, double * y) const
    {
	*x = (*x - extent_.minx()) * sx_ - offset_x_;
	*y = (extent_.maxy() - *y) * sy_ - offset_y_;
    }

    inline void backward(double * x, double * y) const
    {
	*x = extent_.minx() + (*x + offset_x_)/sx_;
	*y = extent_.maxy() - (*y + offset_y_)/sy_;
    }

    inline coord2d& forward(coord2d& c) const
    {
	forward(&c.x,&c.y);
	return c;
    }

    inline coord2d& backward(coord2d& c) const
    {
	backward(&c.x,&c.y);
	return c;
    }

    inline box2d<double> forward(const box2d<double>& e) const
    {
	double x0 = e.minx();
	double y0 = e.miny();
	double x1 = e.maxx();
	double y1 = e.maxy();
	forward(&x0,&y0);
	forward(&x1,&y1);
	return box2d<double>(x0,y0,x1,y1);
    }

    inline box2d<double> backward(const box2d<double>& e) const
    {
	double x0 = e.minx();
	double y0 = e.miny();
	double x1 = e.maxx();
	double y1 = e.maxy();
	backward(&x0,&y0);
	backward(&x1,&y1);
	return box2d<double>(x0,y0,x1,y1);
    }

    inline CoordinateArray& forward(CoordinateArray& coords) const
    {
	for (unsigned i=0;i<coords.size();++i)
	{
	    forward(coords[i]);
	}
	return coords;
    }

    inline CoordinateArray& backward(CoordinateArray& coords) const
    {
	for (unsigned i=0;i<coords.size();++i)
	{
	    backward(coords[i]);
	}
	return coords;
    }
    inline box2d<double> const& extent() const
    {
	return extent_;
    }
};
}

#endif //CTRANS_HPP
<|endoftext|>


<commit_before>#ifndef SLICPLUSPLUS_ENGINE_HPP_
#define SLICPLUSPLUS_ENGINE_HPP_

#include "Actions.hpp"
#include "FramedStream.hpp"
#include "LLStream.hpp"
#include "NetConnection.hpp"
#include "Run.hpp"
#include "TcpSocket.hpp"
#include "UdpSocket.hpp"

SLIC_BEGIN_NAMESPACE

class Engine {
	const MaxFile& mf;
	std::unique_ptr<max_engine_t, decltype(max_unload)*> e;

public:
	explicit Engine(const MaxFile& maxfile, const std::string& id="*")
	 : mf(mf), e(max_load(maxfile.get(), id.c_str()), max_unload)
	{
		if (!e) throw std::runtime_error("Failed to load maxfile");
		max_errors_mode(e->errors, 0);
	}

	max_engine_t* get() const noexcept {
		return e.get();
	}

	max_engine_t* release() noexcept {
		return e.release();
	}

	const MaxFile& getMaxFile() const noexcept {
		return mf;
	}

	void run(const Actions& actions) {
		max_run(e.get(), actions.get());
		SLIC_CHECK_ERRORS(e->errors)
	}

	Run runNonBlock(const Actions& actions) {
		auto ret = Run(max_run_nonblock(e.get(), actions.get()));
		SLIC_CHECK_ERRORS(e->errors)
		return ret;
	}

	void reload(const MaxFile& maxfile) {
		max_reload(e.get(), maxfile.get());
		SLIC_CHECK_ERRORS(e->errors)
	}

	void unlock() {
		max_unlock(e.get());
		SLIC_CHECK_ERRORS(e->errors)
	}

	bool isTimesourceReady() {
		auto ret = max_is_timesource_ready(e.get());
		SLIC_CHECK_ERRORS(e->errors)
		return ret;
	}

	void setTimesourceThreshold(uint32_t nsecs) {
		max_set_timesource_threshold(e.get(), nsecs);
		SLIC_CHECK_ERRORS(e->errors)
	}

	NetConnection getNetworkConnection(max_net_connection_t connection) const noexcept {
		return { e.get(), connection };
	}

	NetConnection getTcpStreamNetworkConnection(const std::string& streamName) {
		auto mf  = getMaxFile().get();
		auto ret = getNetworkConnection(max_tcp_get_network_connection(mf, streamName.c_str()));
		SLIC_CHECK_ERRORS(mf->errors)
		return ret;
	}

	NetConnection getUdpStreamNetworkConnection(const std::string& streamName) {
		auto mf  = getMaxFile().get();
		auto ret = getNetworkConnection(max_udp_get_network_connection(mf, streamName.c_str()));
		SLIC_CHECK_ERRORS(mf->errors)
		return ret;
	}

	LowLatencyInputStream createLowLatencyInputStream(
			const std::string& name, size_t slotSize, size_t numSlots=LowLatencyStream::MAX_SLOTS)
	{
		return { e.get(), name, numSlots, slotSize };
	}

	LowLatencyOutputStream createLowLatencyOutputStream(
			const std::string& name, size_t slotSize, size_t numSlots=LowLatencyStream::MAX_SLOTS)
	{
		return { e.get(), name, numSlots, slotSize };
	}

	FramedInputStream createFramedInputStream(const std::string& name, size_t bufferSize, size_t maxFrameSize) {
		return { e.get(), name, bufferSize, maxFrameSize };
	}

	FramedOutputStream createFramedOutputStream(const std::string& name, size_t bufferSize) {
		return { e.get(), name, bufferSize };
	}

	TcpSocket createTcpSocket(const std::string& name) {
		return { e.get(), name };
	}

	TcpSocket createTcpSocket(const std::string& name, uint16_t socketNumber) {
		return { e.get(), name, socketNumber };
	}

	UdpSocket createUdpSocket(const std::string& name) {
		return { e.get(), name };
	}

	UdpSocket createUdpSocket(const std::string& name, uint16_t socketNumber) {
		return { e.get(), name, socketNumber };
	}
};

SLIC_END_NAMESPACE

#endif /* SLICPLUSPLUS_ENGINE_HPP_ */
<commit_msg>Default buffer size argument.<commit_after>#ifndef SLICPLUSPLUS_ENGINE_HPP_
#define SLICPLUSPLUS_ENGINE_HPP_

#include "Actions.hpp"
#include "FramedStream.hpp"
#include "LLStream.hpp"
#include "NetConnection.hpp"
#include "Run.hpp"
#include "TcpSocket.hpp"
#include "UdpSocket.hpp"

SLIC_BEGIN_NAMESPACE

class Engine {
	const MaxFile& mf;
	std::unique_ptr<max_engine_t, decltype(max_unload)*> e;

public:
	explicit Engine(const MaxFile& maxfile, const std::string& id="*")
	 : mf(mf), e(max_load(maxfile.get(), id.c_str()), max_unload)
	{
		if (!e) throw std::runtime_error("Failed to load maxfile");
		max_errors_mode(e->errors, 0);
	}

	max_engine_t* get() const noexcept {
		return e.get();
	}

	max_engine_t* release() noexcept {
		return e.release();
	}

	const MaxFile& getMaxFile() const noexcept {
		return mf;
	}

	void run(const Actions& actions) {
		max_run(e.get(), actions.get());
		SLIC_CHECK_ERRORS(e->errors)
	}

	Run runNonBlock(const Actions& actions) {
		auto ret = Run(max_run_nonblock(e.get(), actions.get()));
		SLIC_CHECK_ERRORS(e->errors)
		return ret;
	}

	void reload(const MaxFile& maxfile) {
		max_reload(e.get(), maxfile.get());
		SLIC_CHECK_ERRORS(e->errors)
	}

	void unlock() {
		max_unlock(e.get());
		SLIC_CHECK_ERRORS(e->errors)
	}

	bool isTimesourceReady() {
		auto ret = max_is_timesource_ready(e.get());
		SLIC_CHECK_ERRORS(e->errors)
		return ret;
	}

	void setTimesourceThreshold(uint32_t nsecs) {
		max_set_timesource_threshold(e.get(), nsecs);
		SLIC_CHECK_ERRORS(e->errors)
	}

	NetConnection getNetworkConnection(max_net_connection_t connection) const noexcept {
		return { e.get(), connection };
	}

	NetConnection getTcpStreamNetworkConnection(const std::string& streamName) {
		auto mf  = getMaxFile().get();
		auto ret = getNetworkConnection(max_tcp_get_network_connection(mf, streamName.c_str()));
		SLIC_CHECK_ERRORS(mf->errors)
		return ret;
	}

	NetConnection getUdpStreamNetworkConnection(const std::string& streamName) {
		auto mf  = getMaxFile().get();
		auto ret = getNetworkConnection(max_udp_get_network_connection(mf, streamName.c_str()));
		SLIC_CHECK_ERRORS(mf->errors)
		return ret;
	}

	LowLatencyInputStream createLowLatencyInputStream(
			const std::string& name, size_t slotSize, size_t numSlots=LowLatencyStream::MAX_SLOTS)
	{
		return { e.get(), name, numSlots, slotSize };
	}

	LowLatencyOutputStream createLowLatencyOutputStream(
			const std::string& name, size_t slotSize, size_t numSlots=LowLatencyStream::MAX_SLOTS)
	{
		return { e.get(), name, numSlots, slotSize };
	}

	FramedInputStream createFramedInputStream(
			const std::string& name, size_t maxFrameSize, size_t bufferSize=FramedStream::MAX_BUFFER_SIZE)
	{
		return { e.get(), name, bufferSize, maxFrameSize };
	}

	FramedOutputStream createFramedOutputStream(
			const std::string& name, size_t bufferSize=FramedStream::MAX_BUFFER_SIZE)
	{
		return { e.get(), name, bufferSize };
	}

	TcpSocket createTcpSocket(const std::string& name) {
		return { e.get(), name };
	}

	TcpSocket createTcpSocket(const std::string& name, uint16_t socketNumber) {
		return { e.get(), name, socketNumber };
	}

	UdpSocket createUdpSocket(const std::string& name) {
		return { e.get(), name };
	}

	UdpSocket createUdpSocket(const std::string& name, uint16_t socketNumber) {
		return { e.get(), name, socketNumber };
	}
};

SLIC_END_NAMESPACE

#endif /* SLICPLUSPLUS_ENGINE_HPP_ */
<|endoftext|>