-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathFieldOp.cpp
More file actions
79 lines (70 loc) · 1.64 KB
/
Copy pathFieldOp.cpp
File metadata and controls
79 lines (70 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) 2009, Object Computing, Inc.
// All rights reserved.
// See the file license.txt for licensing information.
#include <Common/QuickFASTPch.h>
#include "FieldOp.h"
#include <Codecs/DictionaryIndexer.h>
#include <Codecs/Context.h>
#include <Common/Exceptions.h>
using namespace QuickFAST;
using namespace Codecs;
FieldOp::FieldOp()
: valueIsDefined_(false)
, dictionaryIndex_(0)
, dictionaryIndexValid_(false)
{
}
void
FieldOp::indexDictionaries(
DictionaryIndexer & indexer,
const std::string & dictionaryName,
const std::string & typeName,
const std::string & typeNamespace,
const std::string & fieldName,
const std::string & fieldNamespace)
{
if(usesDictionary())
{
std::string name = dictionaryName;
if(!dictionaryName_.empty())
{
name = dictionaryName_;
}
std::string key = fieldName;
std::string keyNamespace = fieldNamespace;
if(!key_.empty())
{
key = key_;
keyNamespace = keyNamespace_;
}
dictionaryIndex_ = indexer.getIndex(
dictionaryName,
typeName,
typeNamespace,
key,
keyNamespace);
dictionaryIndexValid_ = true;
}
}
void
FieldOp::setDictionaryValue(
Context & context,
const Messages::FieldCPtr & value)
{
if(!dictionaryIndexValid_)
{
throw TemplateDefinitionError("No index available for field.");
}
context.setDictionaryField(dictionaryIndex_, value);
}
bool
FieldOp::findDictionaryField(
Context & context,
Messages::FieldCPtr & value)
{
if(!dictionaryIndexValid_)
{
throw TemplateDefinitionError("No index available for field.");
}
return context.findDictionaryField(dictionaryIndex_, value);
}