-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
496 extend comment syntax in khiops dictionaries #503
base: dev
Are you sure you want to change the base?
Changes from all commits
13a9082
e2630a2
00a167f
5ab495f
110b87f
8aa65f4
e963abe
163aede
bc02e22
3d9f600
ef6d196
ec69292
a76d4ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,18 @@ boolean KWAttributeBlock::Check() const | |
if (not KWClass::CheckName(GetName(), KWClass::AttributeBlock, this)) | ||
bOk = false; | ||
|
||
// Verification du Label | ||
if (not KWClass::CheckLabel(GetLabel(), KWClass::AttributeBlock, this)) | ||
bOk = false; | ||
|
||
// Verification des commentaires | ||
if (not KWClass::CheckComments(GetComments(), KWClass::AttributeBlock, this)) | ||
bOk = false; | ||
|
||
// Verification des commentaires internes | ||
if (not KWClass::CheckComments(GetInternalComments(), KWClass::AttributeBlock, this)) | ||
bOk = false; | ||
|
||
// Tests de base sur la specification du block | ||
if (bOk and firstAttribute == NULL) | ||
{ | ||
|
@@ -746,6 +758,8 @@ longint KWAttributeBlock::GetUsedMemory() const | |
lUsedMemory = sizeof(KWAttributeBlock); | ||
lUsedMemory += usName.GetUsedMemory(); | ||
lUsedMemory += usLabel.GetUsedMemory(); | ||
lUsedMemory += svComments.GetUsedMemory(); | ||
lUsedMemory += svInternalComments.GetUsedMemory(); | ||
lUsedMemory += metaData.GetUsedMemory() - sizeof(KWMetaData); | ||
|
||
// Prise en compte de la regle de derivation | ||
|
@@ -778,42 +792,88 @@ longint KWAttributeBlock::ComputeHashValue() const | |
|
||
void KWAttributeBlock::Write(ostream& ost) const | ||
{ | ||
KWAttribute* secondAttribute; | ||
KWClass* parentClass; | ||
KWAttribute* attribute; | ||
int i; | ||
|
||
ost << '{'; | ||
if (firstAttribute != NULL) | ||
// Commentaires prededents le debut du bloc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/prededents/precedant/ (present participle). |
||
for (i = 0; i < GetComments()->GetSize(); i++) | ||
ost << "\t// " << GetComments()->GetAt(i) << "\n"; | ||
ost << "\t{\n"; | ||
|
||
// Attributs du bloc | ||
parentClass = GetParentClass(); | ||
attribute = firstAttribute; | ||
while (attribute != NULL) | ||
{ | ||
ost << firstAttribute->GetName(); | ||
// Ecriture de l'attribut | ||
ost << *attribute << "\n"; | ||
|
||
// Arret si derniere variable du bloc trouvee | ||
if (attribute == lastAttribute) | ||
break; | ||
|
||
// Passage a l'attribut suivant | ||
parentClass->GetNextAttribute(attribute); | ||
} | ||
|
||
// Acces au deuxieme attribut | ||
secondAttribute = firstAttribute; | ||
if (GetParentClass() != NULL) | ||
GetParentClass()->GetNextAttribute(secondAttribute); | ||
// Commentaires internes precedents la fin du bloc | ||
for (i = 0; i < GetInternalComments()->GetSize(); i++) | ||
ost << "\t// " << GetInternalComments()->GetAt(i) << "\n"; | ||
ost << "\t}"; | ||
|
||
// Si au moins trois attributs | ||
if (lastAttribute != NULL and secondAttribute != NULL and lastAttribute != secondAttribute) | ||
ost << ",..., "; | ||
// Nom du bloc | ||
ost << "\t" << KWClass::GetExternalName(GetName()); | ||
ost << "\t"; | ||
|
||
// Dernier attribut si au moins deux attributs | ||
if (lastAttribute != NULL and lastAttribute != firstAttribute) | ||
ost << ", " + lastAttribute->GetName(); | ||
// Regle de derivation | ||
if (GetDerivationRule() != NULL) | ||
{ | ||
// Dans le cas de la regle predefinie de Reference, on n'utilise pas le signe '=' | ||
if (GetDerivationRule()->GetName() != KWDerivationRule::GetReferenceRuleName()) | ||
ost << " = "; | ||
GetDerivationRule()->WriteUsedRule(ost); | ||
} | ||
ost << "}\t" << GetName() << endl; | ||
|
||
// Fin de declaration | ||
ost << "\t;"; | ||
|
||
// Meta-donnees | ||
if (GetConstMetaData()->GetKeyNumber() > 0) | ||
{ | ||
ost << ' '; | ||
GetConstMetaData()->Write(ost); | ||
} | ||
ost << "\t"; | ||
|
||
// Libelle | ||
if (GetLabel() != "") | ||
ost << "// " << GetLabel(); | ||
} | ||
|
||
void KWAttributeBlock::WriteJSONFields(JSONFile* fJSON) | ||
{ | ||
KWClass* parentClass; | ||
KWAttribute* attribute; | ||
ALString sOutputString; | ||
int i; | ||
|
||
// Nom | ||
fJSON->WriteKeyString("blockName", GetName()); | ||
|
||
// Commentaire | ||
// Libelle | ||
if (GetLabel() != "") | ||
fJSON->WriteKeyString("label", GetLabel()); | ||
|
||
// Commentaire | ||
if (GetComments()->GetSize() > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would discard the test and write the |
||
{ | ||
fJSON->BeginKeyArray("comments"); | ||
for (i = 0; i < GetComments()->GetSize(); i++) | ||
fJSON->WriteString(GetComments()->GetAt(i)); | ||
fJSON->EndArray(); | ||
} | ||
|
||
// Regle de derivation | ||
if (kwdrRule != NULL) | ||
{ | ||
|
@@ -842,6 +902,15 @@ void KWAttributeBlock::WriteJSONFields(JSONFile* fJSON) | |
parentClass->GetNextAttribute(attribute); | ||
} | ||
fJSON->EndArray(); | ||
|
||
// Commentaires internes | ||
if (GetInternalComments()->GetSize() > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idem, I would write the |
||
{ | ||
fJSON->BeginKeyArray("internalComments"); | ||
for (i = 0; i < GetInternalComments()->GetSize(); i++) | ||
fJSON->WriteString(GetInternalComments()->GetAt(i)); | ||
fJSON->EndArray(); | ||
} | ||
} | ||
|
||
const ALString KWAttributeBlock::GetClassLabel() const | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether it wouldn't be more consistent to keep the contents of the
if
block in all cases, that is, havecomments
array even when there is no comment (i.e.GetComments()->GetSize() == 0
- in this case the array would just be empty, because thefor
loop would not have what to iterate on).