vcard4: Use VC_Param instead of VCParam for consistency.
This commit is contained in:
parent
5565087359
commit
ddddcf0af9
@ -228,7 +228,7 @@ type
|
|||||||
VC4_Property* = ref object of RootObj
|
VC4_Property* = ref object of RootObj
|
||||||
propertyId: int
|
propertyId: int
|
||||||
group*: Option[string]
|
group*: Option[string]
|
||||||
params*: seq[VCParam]
|
params*: seq[VC_Param]
|
||||||
|
|
||||||
VC4_DateTimeOrTextProperty* = ref object of VC4_Property
|
VC4_DateTimeOrTextProperty* = ref object of VC4_Property
|
||||||
valueType: VC4_ValueType # should only be vtDateAndOrTime or vtText
|
valueType: VC4_ValueType # should only be vtDateAndOrTime or vtText
|
||||||
@ -360,9 +360,9 @@ template takePropertyId(vc4: VCard4): int =
|
|||||||
vc4.nextPropertyId - 1
|
vc4.nextPropertyId - 1
|
||||||
|
|
||||||
func flattenParameters(
|
func flattenParameters(
|
||||||
params: seq[VCParam],
|
params: seq[VC_Param],
|
||||||
addtlParams: varargs[VCParam] = @[]
|
addtlParams: varargs[VC_Param] = @[]
|
||||||
): seq[VCParam] =
|
): seq[VC_Param] =
|
||||||
|
|
||||||
let paramTable = newTable[string, seq[string]]()
|
let paramTable = newTable[string, seq[string]]()
|
||||||
let allParams = params & toSeq(addtlParams)
|
let allParams = params & toSeq(addtlParams)
|
||||||
@ -451,7 +451,7 @@ proc parseTimestamp(value: string): DateTime =
|
|||||||
except: discard
|
except: discard
|
||||||
raise newException(VCardParsingError, "unable to parse timestamp value: " & value)
|
raise newException(VCardParsingError, "unable to parse timestamp value: " & value)
|
||||||
|
|
||||||
func parsePidValues(param: VCParam): seq[PidValue]
|
func parsePidValues(param: VC_Param): seq[PidValue]
|
||||||
{.raises:[VCardParsingError].} =
|
{.raises:[VCardParsingError].} =
|
||||||
|
|
||||||
result = @[]
|
result = @[]
|
||||||
@ -466,7 +466,7 @@ func parsePidValues(param: VCParam): seq[PidValue]
|
|||||||
raise newException(VCardParsingError, "PID value expected to be two " &
|
raise newException(VCardParsingError, "PID value expected to be two " &
|
||||||
"integers separated by '.' (2.1 for example)")
|
"integers separated by '.' (2.1 for example)")
|
||||||
|
|
||||||
template validateType(p: VCardParser, params: seq[VCParam], t: VC4_ValueType) =
|
template validateType(p: VCardParser, params: seq[VC_Param], t: VC4_ValueType) =
|
||||||
p.validateRequiredParameters(params, [("VALUE", $t)])
|
p.validateRequiredParameters(params, [("VALUE", $t)])
|
||||||
|
|
||||||
func cmp[T: VC4_Property](x, y: T): int =
|
func cmp[T: VC4_Property](x, y: T): int =
|
||||||
@ -576,7 +576,7 @@ macro genDateTimeOrTextPropInitializers(
|
|||||||
value: DateTime,
|
value: DateTime,
|
||||||
altId: Option[string] = none[string](),
|
altId: Option[string] = none[string](),
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[]): typeName =
|
params: seq[VC_Param] = @[]): typeName =
|
||||||
return typeName(
|
return typeName(
|
||||||
params: flattenParameters(params,
|
params: flattenParameters(params,
|
||||||
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
||||||
@ -597,7 +597,7 @@ macro genDateTimeOrTextPropInitializers(
|
|||||||
valueType: Option[string] = some($vtDateAndOrTime),
|
valueType: Option[string] = some($vtDateAndOrTime),
|
||||||
altId: Option[string] = none[string](),
|
altId: Option[string] = none[string](),
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[]): typeName =
|
params: seq[VC_Param] = @[]): typeName =
|
||||||
result = typeName(
|
result = typeName(
|
||||||
params: flattenParameters(params,
|
params: flattenParameters(params,
|
||||||
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
||||||
@ -625,7 +625,7 @@ macro genTextPropInitializers(
|
|||||||
value: string,
|
value: string,
|
||||||
altId: Option[string] = none[string](),
|
altId: Option[string] = none[string](),
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[]): typeName =
|
params: seq[VC_Param] = @[]): typeName =
|
||||||
return typeName(
|
return typeName(
|
||||||
params: flattenParameters(params,
|
params: flattenParameters(params,
|
||||||
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
||||||
@ -648,7 +648,7 @@ macro genTextListPropInitializers(
|
|||||||
value: seq[string],
|
value: seq[string],
|
||||||
altId: Option[string] = none[string](),
|
altId: Option[string] = none[string](),
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[]): typeName =
|
params: seq[VC_Param] = @[]): typeName =
|
||||||
return typeName(
|
return typeName(
|
||||||
params: flattenParameters(params,
|
params: flattenParameters(params,
|
||||||
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
||||||
@ -671,7 +671,7 @@ macro genTextOrUriPropInitializers(
|
|||||||
isUrl = false,
|
isUrl = false,
|
||||||
altId: Option[string] = none[string](),
|
altId: Option[string] = none[string](),
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[]): typeName =
|
params: seq[VC_Param] = @[]): typeName =
|
||||||
return typeName(
|
return typeName(
|
||||||
params: flattenParameters(params,
|
params: flattenParameters(params,
|
||||||
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
||||||
@ -694,7 +694,7 @@ macro genUriPropInitializers(
|
|||||||
altId: Option[string] = none[string](),
|
altId: Option[string] = none[string](),
|
||||||
mediaType: Option[string] = none[string](),
|
mediaType: Option[string] = none[string](),
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[]): typeName =
|
params: seq[VC_Param] = @[]): typeName =
|
||||||
return typeName(
|
return typeName(
|
||||||
params: flattenParameters(params,
|
params: flattenParameters(params,
|
||||||
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
("ALTID", if altId.isSome: @[altId.get] else: @[])),
|
||||||
@ -728,7 +728,7 @@ func newVC4_N*(
|
|||||||
suffixes: seq[string] = @[],
|
suffixes: seq[string] = @[],
|
||||||
altId: Option[string] = none[string](),
|
altId: Option[string] = none[string](),
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[]): VC4_N =
|
params: seq[VC_Param] = @[]): VC4_N =
|
||||||
|
|
||||||
return assignFields(
|
return assignFields(
|
||||||
VC4_N(params: flattenParameters(params,
|
VC4_N(params: flattenParameters(params,
|
||||||
@ -740,7 +740,7 @@ func newVC4_Gender*(
|
|||||||
genderIdentity: Option[string] = none[string](),
|
genderIdentity: Option[string] = none[string](),
|
||||||
altId: Option[string] = none[string](),
|
altId: Option[string] = none[string](),
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[]): VC4_Gender =
|
params: seq[VC_Param] = @[]): VC4_Gender =
|
||||||
|
|
||||||
return assignFields(
|
return assignFields(
|
||||||
VC4_Gender(params: flattenParameters(params,
|
VC4_Gender(params: flattenParameters(params,
|
||||||
@ -760,7 +760,7 @@ func newVC4_Adr*(
|
|||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
label: Option[string] = none[string](),
|
label: Option[string] = none[string](),
|
||||||
language: Option[string] = none[string](),
|
language: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[],
|
params: seq[VC_Param] = @[],
|
||||||
pids: seq[PidValue] = @[],
|
pids: seq[PidValue] = @[],
|
||||||
pref: Option[int] = none[int](),
|
pref: Option[int] = none[int](),
|
||||||
types: seq[string] = @[],
|
types: seq[string] = @[],
|
||||||
@ -785,7 +785,7 @@ func newVC4_ClientPidMap*(
|
|||||||
id: int,
|
id: int,
|
||||||
uri: string,
|
uri: string,
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam] = @[]): VC4_ClientPidMap =
|
params: seq[VC_Param] = @[]): VC4_ClientPidMap =
|
||||||
|
|
||||||
result = assignFields(
|
result = assignFields(
|
||||||
VC4_ClientPidMap(params: flattenParameters(params)),
|
VC4_ClientPidMap(params: flattenParameters(params)),
|
||||||
@ -794,7 +794,7 @@ func newVC4_ClientPidMap*(
|
|||||||
func newVC4_Rev*(
|
func newVC4_Rev*(
|
||||||
value: DateTime,
|
value: DateTime,
|
||||||
group: Option[string] = none[string](),
|
group: Option[string] = none[string](),
|
||||||
params: seq[VCParam]= @[]): VC4_Rev =
|
params: seq[VC_Param]= @[]): VC4_Rev =
|
||||||
|
|
||||||
return assignFields(
|
return assignFields(
|
||||||
VC4_Rev(params: flattenParameters(params)),
|
VC4_Rev(params: flattenParameters(params)),
|
||||||
@ -1057,7 +1057,7 @@ func serializeParamValue(value: string): string =
|
|||||||
result = "\"" & result & "\""
|
result = "\"" & result & "\""
|
||||||
break
|
break
|
||||||
|
|
||||||
func serialize(params: seq[VCParam]): string =
|
func serialize(params: seq[VC_Param]): string =
|
||||||
result = ""
|
result = ""
|
||||||
for pLent in params:
|
for pLent in params:
|
||||||
let p = pLent
|
let p = pLent
|
||||||
@ -1145,11 +1145,11 @@ proc readParamValue(p: var VCardParser): string =
|
|||||||
p.error("quoted parameter value expected to end with a " &
|
p.error("quoted parameter value expected to end with a " &
|
||||||
"double quote (\")")
|
"double quote (\")")
|
||||||
|
|
||||||
proc readParams(p: var VCardParser): seq[VCParam] =
|
proc readParams(p: var VCardParser): seq[VC_Param] =
|
||||||
result = @[]
|
result = @[]
|
||||||
while p.peek == ';':
|
while p.peek == ';':
|
||||||
discard p.read
|
discard p.read
|
||||||
var param: VCParam = (p.readName, @[])
|
var param: VC_Param = (p.readName, @[])
|
||||||
p.expect("=", true)
|
p.expect("=", true)
|
||||||
param.values.add(p.readParamValue)
|
param.values.add(p.readParamValue)
|
||||||
while p.peek == ',':
|
while p.peek == ',':
|
||||||
@ -1244,7 +1244,7 @@ macro genPropParsers(
|
|||||||
genProps: static[openarray[(VC4_PropertyName, VC4_ValueType)]],
|
genProps: static[openarray[(VC4_PropertyName, VC4_ValueType)]],
|
||||||
group: Option[string],
|
group: Option[string],
|
||||||
name: string,
|
name: string,
|
||||||
params: seq[VCParam],
|
params: seq[VC_Param],
|
||||||
contents: var seq[VC4_Property],
|
contents: var seq[VC4_Property],
|
||||||
p: var VCardParser
|
p: var VCardParser
|
||||||
): untyped =
|
): untyped =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user