Menu

[r8]: / trunk / bindings / lua / FunctionOptions.cpp  Maximize  Restore  History

Download this file

192 lines (169 with data), 5.4 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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// stl
#include <iostream>
#include <algorithm>
// Lua
#include "luaxx/luaxx.h"
// SubCpp
//#include "../../revision.hpp"
#include "FunctionOptions.h"
#include "BindRevision.h"
svn_depth_t BindFunctionOptions::StringToDepth( std::string strDepth )
{
svn_depth_t retVal = svn_depth_unknown;
// Make the string lower case so the comparision can be
std::transform( strDepth.begin(), strDepth.end(), strDepth.begin(), ::tolower );
if ( "empty" == strDepth )
{
retVal = svn_depth_empty;
}
else if ( "infinity" == strDepth )
{
retVal = svn_depth_infinity;
}
else if ( "files" == strDepth )
{
retVal = svn_depth_files;
}
else if ( "immediates" == strDepth )
{
retVal = svn_depth_immediates;
}
return retVal;
}
void BindFunctionOptions::To( lua_State* luaState, FunctionOptions& options, int index /*= -1*/ )
{
lua::state lState( luaState );
if ( lState.istable( index ) )
{
lState.getfield( "revision", index );
if ( !lState.isnoneornil() )
{
// Check what the revision
BindRevision::To( lState, options.m_revision );
// Default peg to revision so that it acts as the client does.
options.m_peg = options.m_revision;
}
lState.pop(); // revision cleanup
lState.getfield( "peg", index );
if ( !lState.isnoneornil() )
{
// Check what the revision
BindRevision::To( lState, options.m_peg );
}
lState.pop(); // peg cleanup
lState.getfield( "depth", index );
if ( !lState.isnoneornil() )
{
// Check for a supplied depth
if ( "number" == lState.type_name() )
{
// Help VC with casting from an enum to a number
options.m_depth = static_cast< svn_depth_t >( lState.as< int >( options.m_depth ) );
}
else
{
std::string optDepth;
lState.to( optDepth );
options.m_depth = StringToDepth( optDepth );
}
}
lState.pop(); // depth cleanup
lState.getfield( "ignore_externals", index );
if ( !lState.isnoneornil() )
{
// Check if we should ignore externals
options.m_shouldIgnoreExternals = lState.as( options.m_shouldIgnoreExternals );
}
lState.pop(); // ignore_externals cleanup
lState.getfield( "ignore_keywords", index );
if ( !lState.isnoneornil() )
{
// Check if we should ignore externals
options.m_shouldIgnoreKeywords = lState.as( options.m_shouldIgnoreKeywords );
}
lState.pop(); // ignore_keywords cleanup
lState.getfield( "no_ignore", index );
if ( !lState.isnoneornil() )
{
// Check if we should ignore externals
options.m_shouldIgnoreIgnore = lState.as( options.m_shouldIgnoreIgnore );
}
lState.pop(); // no_ignore cleanup
lState.getfield( "force", index );
if ( !lState.isnoneornil() )
{
// Check if we should ignore externals
options.m_shouldForce = lState.as( options.m_shouldForce );
}
lState.pop(); // force cleanup
lState.getfield( "native_eol", index );
if ( !lState.isnoneornil() )
{
// Check if we should change the files EOL marker.
options.m_nativeEolMarker = lState.as( options.m_nativeEolMarker );
}
lState.pop(); // native_eol cleanup
lState.getfield( "set_depth", index );
if ( !lState.isnoneornil() )
{
// Check if we should set the depth to the WC.
options.m_shouldSetDepth = lState.as( options.m_shouldSetDepth );
}
lState.pop(); // set_depth cleanup
lState.getfield( "parents", index );
if ( !lState.isnoneornil() )
{
// Check if we should set adding parents till a versioned dir is found.
options.m_shouldMakeParents = lState.as( options.m_shouldMakeParents );
}
lState.pop(); // parents cleanup
lState.getfield( "add_parents", index );
if ( !lState.isnoneornil() )
{
// Check if we should set adding parents till a versioned dir is found.
options.m_shouldAddParents = lState.as( options.m_shouldAddParents );
}
lState.pop(); // add_parents cleanup
lState.getfield( "keep_locks", index );
if ( !lState.isnoneornil() )
{
// Check if we should keep the locked files locked after a commit.
options.m_shouldKeepLocks = lState.as( options.m_shouldKeepLocks );
}
lState.pop(); // keep_locks cleanup
lState.getfield( "keep_changelists", index );
if ( !lState.isnoneornil() )
{
// Check if we should keep the changelist after the commit.
options.m_shouldKeepChangelists = lState.as( options.m_shouldKeepChangelists );
}
lState.pop(); // keep_changelists cleanup
lState.getfield( "auto_props", index );
if ( !lState.isnoneornil() )
{
// Check if we should use the auto-props set in the context.
options.m_shouldEnableAutoProps = lState.as( options.m_shouldEnableAutoProps );
}
lState.pop(); // auto_props cleanup
lState.getfield( "ignore_unknown_node_types", index );
if ( !lState.isnoneornil() )
{
// Check if we should we ignore the unknown node types.
options.m_shouldIgnoreUnknownNodeTypes = lState.as( options.m_shouldIgnoreUnknownNodeTypes );
}
lState.pop(); // ignore_unknown_node_types cleanup
lState.getfield( "keep_local", index );
if ( !lState.isnoneornil() )
{
// Check if we should keep local files after deleting.
options.m_shouldKeepLocal = lState.as( options.m_shouldKeepLocal );
}
lState.pop(); // keep_local cleanup
}
/*else
{
std::string errorMsg = "Options table expected. Found a ";
errorMsg += lState.type_name( index );
throw BindFunctionOptionsEx( errorMsg.c_str() );
}*/
}
MongoDB Logo MongoDB