~ubuntu-branches/debian/squeeze/pycryptopp/squeeze

« back to all changes in this revision

Viewing changes to cryptopp/algparam.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Zooko O'Whielacronx
  • Date: 2009-06-22 22:20:50 UTC
  • Revision ID: james.westby@ubuntu.com-20090622222050-hbqmn50dt2kvoz5o
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// algparam.cpp - written and placed in the public domain by Wei Dai
 
2
 
 
3
#include "pch.h"
 
4
 
 
5
#ifndef CRYPTOPP_IMPORTS
 
6
 
 
7
#include "algparam.h"
 
8
 
 
9
NAMESPACE_BEGIN(CryptoPP)
 
10
 
 
11
PAssignIntToInteger g_pAssignIntToInteger = NULL;
 
12
 
 
13
bool CombinedNameValuePairs::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
 
14
{
 
15
        if (strcmp(name, "ValueNames") == 0)
 
16
                return m_pairs1.GetVoidValue(name, valueType, pValue) && m_pairs2.GetVoidValue(name, valueType, pValue);
 
17
        else
 
18
                return m_pairs1.GetVoidValue(name, valueType, pValue) || m_pairs2.GetVoidValue(name, valueType, pValue);
 
19
}
 
20
 
 
21
void AlgorithmParametersBase::operator=(const AlgorithmParametersBase& rhs)
 
22
{
 
23
        assert(false);
 
24
}
 
25
 
 
26
bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
 
27
{
 
28
        if (strcmp(name, "ValueNames") == 0)
 
29
        {
 
30
                NameValuePairs::ThrowIfTypeMismatch(name, typeid(std::string), valueType);
 
31
                if (m_next.get())
 
32
                    m_next->GetVoidValue(name, valueType, pValue);
 
33
                (*reinterpret_cast<std::string *>(pValue) += m_name) += ";";
 
34
                return true;
 
35
        }
 
36
        else if (strcmp(name, m_name) == 0)
 
37
        {
 
38
                AssignValue(name, valueType, pValue);
 
39
                m_used = true;
 
40
                return true;
 
41
        }
 
42
        else if (m_next.get())
 
43
                return m_next->GetVoidValue(name, valueType, pValue);
 
44
        else
 
45
            return false;
 
46
}
 
47
 
 
48
AlgorithmParameters::AlgorithmParameters()
 
49
        : m_defaultThrowIfNotUsed(true)
 
50
{
 
51
}
 
52
 
 
53
AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x)
 
54
        : m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
 
55
{
 
56
        m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
 
57
}
 
58
 
 
59
AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
 
60
{
 
61
        m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
 
62
        return *this;
 
63
}
 
64
 
 
65
bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
 
66
{
 
67
        if (m_next.get())
 
68
                return m_next->GetVoidValue(name, valueType, pValue);
 
69
        else
 
70
                return false;
 
71
}
 
72
 
 
73
NAMESPACE_END
 
74
 
 
75
#endif