1 /**
2 * @file Style.cpp
3 * @brief Implementation of the Style class.
4 * @author Ralph Gauges
5 * @author Frank T. Bergmann
6 *
7 * <!--------------------------------------------------------------------------
8 * This file is part of libSBML. Please visit http://sbml.org for more
9 * information about SBML, and the latest version of libSBML.
10 *
11 * Copyright (C) 2020 jointly by the following organizations:
12 * 1. California Institute of Technology, Pasadena, CA, USA
13 * 2. University of Heidelberg, Heidelberg, Germany
14 * 3. University College London, London, UK
15 *
16 * Copyright (C) 2019 jointly by the following organizations:
17 * 1. California Institute of Technology, Pasadena, CA, USA
18 * 2. University of Heidelberg, Heidelberg, Germany
19 *
20 * Copyright (C) 2013-2018 jointly by the following organizations:
21 * 1. California Institute of Technology, Pasadena, CA, USA
22 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
23 * 3. University of Heidelberg, Heidelberg, Germany
24 *
25 * Copyright (C) 2011-2013 jointly by the following organizations:
26 * 1. California Institute of Technology, Pasadena, CA, USA
27 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
28 *
29 * Copyright 2010 Ralph Gauges
30 * Group for the modeling of biological processes
31 * University of Heidelberg
32 * Im Neuenheimer Feld 267
33 * 69120 Heidelberg
34 * Germany
35 *
36 * This library is free software; you can redistribute it and/or modify it
37 * under the terms of the GNU Lesser General Public License as published by
38 * the Free Software Foundation. A copy of the license agreement is provided
39 * in the file named "LICENSE.txt" included with this software distribution
40 * and also available online as http://sbml.org/software/libsbml/license.html
41 * ---------------------------------------------------------------------- -->*/
42
43 #include <sbml/packages/render/sbml/Style.h>
44 #include <sbml/packages/layout/util/LayoutAnnotation.h>
45 #include <sbml/packages/layout/util/LayoutUtilities.h>
46 #include <sbml/packages/render/validator/RenderSBMLError.h>
47
48 #include <sbml/packages/render/sbml/GlobalStyle.h>
49 #include <sbml/packages/render/sbml/ListOfGlobalStyles.h>
50 #include <sbml/packages/render/sbml/LocalStyle.h>
51 #include <sbml/packages/render/sbml/ListOfLocalStyles.h>
52
53 #include <sbml/util/ElementFilter.h>
54
55 #ifndef OMIT_DEPRECATED
56 #ifdef DEPRECATION_WARNINGS
57 #include <iostream>
58 #endif // DEPRECATION_WARNINGS
59 #endif // OMIT_DEPRECATED
60
61 #include <sbml/xml/XMLInputStream.h>
62
63 using namespace std;
64
65
66
67 LIBSBML_CPP_NAMESPACE_BEGIN
68
69
70
71
72 #ifdef __cplusplus
73
74
75 /*
76 * Creates a new Style using the given SBML Level, Version and
77 * “render” package version.
78 */
Style(unsigned int level,unsigned int version,unsigned int pkgVersion)79 Style::Style(unsigned int level,
80 unsigned int version,
81 unsigned int pkgVersion)
82 : SBase(level, version)
83 ,mGroup(level,version)
84 {
85 setSBMLNamespacesAndOwn(new RenderPkgNamespaces(level, version, pkgVersion));
86 connectToChild();
87 }
88
89
90 /*
91 * Creates a new Style using the given RenderPkgNamespaces object.
92 */
Style(RenderPkgNamespaces * renderns)93 Style::Style(RenderPkgNamespaces *renderns)
94 : SBase(renderns)
95 ,mGroup(renderns)
96 {
97 setElementNamespace(renderns->getURI());
98 connectToChild();
99 loadPlugins(renderns);
100 }
101
102
103 /*
104 * Creates a new Style object from the given XMLNode object.
105 * The XMLNode object has to contain a valid XML representation of a
106 * Style object as defined in the render extension specification.
107 * This method is normally called when render information is read from a file and
108 * should normally not have to be called explicitly.
109 *
110 * @param node the XMLNode object reference that describes the Style
111 * object to be instantiated.
112 */
Style(const XMLNode & node,unsigned int l2version)113 Style::Style(const XMLNode& node, unsigned int l2version) :
114 SBase(2,l2version),
115 mGroup(2,l2version)
116 {
117 mURI = RenderExtension::getXmlnsL3V1V1();
118
119 const XMLNode* child;
120 const XMLAttributes& attributes=node.getAttributes();
121 ExpectedAttributes ea;
122 addExpectedAttributes(ea);
123 this->readAttributes(attributes, ea);
124 unsigned int n=0,nMax = node.getNumChildren();
125 while(n<nMax)
126 {
127 child=&node.getChild(n);
128 const std::string& childName=child->getName();
129 if(childName=="g")
130 {
131 this->mGroup=RenderGroup(*child);
132 // set the unset values to the defaults
133 if(!this->mGroup.isSetStroke())
134 {
135 this->mGroup.setStroke("none");
136 }
137 if(!this->mGroup.isSetStrokeWidth())
138 {
139 this->mGroup.setStrokeWidth(0.0);
140 }
141 if(!this->mGroup.isSetDashArray())
142 {
143 this->mGroup.setDashArray(std::vector<unsigned int>());
144 }
145 if(!this->mGroup.isSetFillColor())
146 {
147 this->mGroup.setFillColor("none");
148 }
149 if(!this->mGroup.isSetFillRule())
150 {
151 this->mGroup.setFillRule(GraphicalPrimitive2D::NONZERO);
152 }
153 if(!this->mGroup.isSetFontFamily())
154 {
155 this->mGroup.setFontFamily("sans-serif");
156 }
157 if(!this->mGroup.isSetFontSize())
158 {
159 this->mGroup.setFontSize(0);
160 }
161 if(!this->mGroup.isSetFontWeight())
162 {
163 this->mGroup.setFontWeight(Text::WEIGHT_NORMAL);
164 }
165 if(!this->mGroup.isSetFontStyle())
166 {
167 this->mGroup.setFontStyle(Text::STYLE_NORMAL);
168 }
169 if(!this->mGroup.isSetStartHead())
170 {
171 this->mGroup.setStartHead("none");
172 }
173 if(!this->mGroup.isSetEndHead())
174 {
175 this->mGroup.setEndHead("none");
176 }
177 }
178 else if(childName=="annotation")
179 {
180 this->mAnnotation=new XMLNode(*child);
181 }
182 else if(childName=="notes")
183 {
184 this->mNotes=new XMLNode(*child);
185 }
186 ++n;
187 }
188
189
190 setSBMLNamespacesAndOwn(new RenderPkgNamespaces(2,l2version));
191
192 connectToChild();
193 }
194
195
196 #ifndef OMIT_DEPRECATED
197 /** @cond doxygenLibsbmlInternal */
198 /*
199 * Constructor which creates a Style with an empty group
200 * and empty role and type list.
201 * The group has to be filled before the * object is valid.
202 *
203 * This constructor is deprecated. The new libsbml API only has
204 * constructors which take the SBML level and version or one that takes
205 * an SBMLNamespaces object.
206 */
Style(RenderPkgNamespaces * renderns,const std::string & id)207 Style::Style(RenderPkgNamespaces* renderns, const std::string& id):
208 SBase(renderns)
209 // ,mId(id)
210 ,mGroup(renderns)
211 {
212 #ifdef DEPRECATION_WARNINGS
213 std::cerr << "Warning. Style::Style(const std::string& id) is deprecated." << std::endl;
214 #endif // DEPRECATION_WARNINGS
215 setId(id);
216
217 // set the element namespace of this object
218 setElementNamespace(renderns->getURI());
219
220 // connect child elements to this element.
221 connectToChild();
222
223 // load package extensions bound with this object (if any)
224 loadPlugins(renderns);
225 }
226 /** @endcond */
227 #endif // OMIT_DEPRECATED
228
229 /*
230 * Copy constructor for Style.
231 */
Style(const Style & orig)232 Style::Style(const Style& orig)
233 : SBase( orig )
234 , mRoleList ( orig.mRoleList )
235 , mTypeList ( orig.mTypeList )
236 , mGroup ( orig.mGroup )
237 {
238 connectToChild();
239 }
240
241
242 /*
243 * Assignment operator for Style.
244 */
245 Style&
operator =(const Style & rhs)246 Style::operator=(const Style& rhs)
247 {
248 if (&rhs != this)
249 {
250 SBase::operator=(rhs);
251 mRoleList = rhs.mRoleList;
252 mTypeList = rhs.mTypeList;
253 mGroup = rhs.mGroup;
254
255 connectToChild();
256 }
257
258 return *this;
259 }
260
261
262 /*
263 * Creates and returns a deep copy of this Style object.
264 */
265 Style*
clone() const266 Style::clone() const
267 {
268 return new Style(*this);
269 }
270
271
272 /*
273 * Destructor for Style.
274 */
~Style()275 Style::~Style()
276 {
277 }
278
279
280 /*
281 * Returns the value of the "id" attribute of this Style.
282 */
283 const std::string&
getId() const284 Style::getId() const
285 {
286 return mId;
287 }
288
289
290 /*
291 * Returns the value of the "name" attribute of this Style.
292 */
293 const std::string&
getName() const294 Style::getName() const
295 {
296 return mName;
297 }
298
299 /*
300 * Predicate returning @c true if this Style's "id" attribute is set.
301 */
302 bool
isSetId() const303 Style::isSetId() const
304 {
305 return (mId.empty() == false);
306 }
307
308
309 /*
310 * Predicate returning @c true if this Style's "name" attribute is set.
311 */
312 bool
isSetName() const313 Style::isSetName() const
314 {
315 return (mName.empty() == false);
316 }
317
318 /*
319 * Sets the value of the "id" attribute of this Style.
320 */
321 int
setId(const std::string & id)322 Style::setId(const std::string& id)
323 {
324 return SyntaxChecker::checkAndSetSId(id, mId);
325 }
326
327
328 /*
329 * Sets the value of the "name" attribute of this Style.
330 */
331 int
setName(const std::string & name)332 Style::setName(const std::string& name)
333 {
334 mName = name;
335 return LIBSBML_OPERATION_SUCCESS;
336 }
337
338
339 /*
340 * Unsets the value of the "id" attribute of this Style.
341 */
342 int
unsetId()343 Style::unsetId()
344 {
345 mId.erase();
346
347 if (mId.empty() == true)
348 {
349 return LIBSBML_OPERATION_SUCCESS;
350 }
351 else
352 {
353 return LIBSBML_OPERATION_FAILED;
354 }
355 }
356
357
358 /*
359 * Unsets the value of the "name" attribute of this Style.
360 */
361 int
unsetName()362 Style::unsetName()
363 {
364 mName.erase();
365
366 if (mName.empty() == true)
367 {
368 return LIBSBML_OPERATION_SUCCESS;
369 }
370 else
371 {
372 return LIBSBML_OPERATION_FAILED;
373 }
374 }
375
376
377 /*
378 * Returns a const reference to the role list.
379 */
getRoleList()380 std::set<std::string>& Style::getRoleList()
381 {
382 return this->mRoleList;
383 }
384
385
386 /*
387 * Returns a const reference to the role list.
388 */
getRoleList() const389 const std::set<std::string>& Style::getRoleList() const
390 {
391 return this->mRoleList;
392 }
393
394
395 /*
396 * Returns the number of ids in the role list.
397 */
getNumRoles() const398 unsigned int Style::getNumRoles() const
399 {
400 return (unsigned int)this->mRoleList.size();
401 }
402
403
404 /*
405 * Checks whether a given role is in the role list.
406 */
isInRoleList(const std::string & id) const407 bool Style::isInRoleList(const std::string& id) const
408 {
409 return (this->mRoleList.find(id)!=this->mRoleList.end());
410 }
411
412
413 /*
414 * Adds an id to the role list.
415 */
416 int
addRole(const std::string & id)417 Style::addRole(const std::string& id)
418 {
419 this->mRoleList.insert(id);
420 return LIBSBML_OPERATION_SUCCESS;
421 }
422
423
424 /*
425 * @return the string of all roles
426 */
427 std::string
createRoleString() const428 Style::createRoleString() const
429 {
430 return createStringFromSet(mRoleList);
431 }
432
433
434 /*
435 * Removes the given role from the role list.
436 */
437 int
removeRole(const std::string & id)438 Style::removeRole(const std::string& id)
439 {
440 this->mRoleList.erase(id);
441 return LIBSBML_OPERATION_SUCCESS;
442 }
443
444
445 /*
446 * Sets the complete role list to a copy of the given list.
447 */
448 int
setRoleList(const std::set<std::string> & roleList)449 Style::setRoleList(const std::set<std::string>& roleList)
450 {
451 // I do not check roles on purpose since this is more versatil in the light
452 // of future extensions
453 this->mRoleList=roleList;
454 return LIBSBML_OPERATION_SUCCESS;
455 }
456
457
458 /*
459 * Returns the type list.
460 */
getTypeList() const461 const std::set<std::string>& Style::getTypeList() const
462 {
463 return this->mTypeList;
464 }
465
466
467 /*
468 * Returns the type list.
469 */
getTypeList()470 std::set<std::string>& Style::getTypeList()
471 {
472 return this->mTypeList;
473 }
474
475
476 /*
477 * Returns the number of types in the type list.
478 */
getNumTypes() const479 unsigned int Style::getNumTypes() const
480 {
481 return (unsigned int)this->mTypeList.size();
482 }
483
484
485 /*
486 * Checks whether a given type string is in the type list.
487 */
isInTypeList(const std::string & id) const488 bool Style::isInTypeList(const std::string& id) const
489 {
490 return (this->mTypeList.find(id) != this->mTypeList.end());
491 }
492
493
494 /*
495 * Adds a type string to the type list.
496 */
497 int
addType(const std::string & id)498 Style::addType(const std::string& id)
499 {
500 this->mTypeList.insert(id);
501 return LIBSBML_OPERATION_SUCCESS;
502 }
503
504
505 /*
506 * @return the string of all types
507 */
508 std::string
createTypeString() const509 Style::createTypeString() const
510 {
511 return createStringFromSet(mTypeList);
512 }
513
514
515 /*
516 * Removes a type string from the type list.
517 */
518 int
removeType(const std::string & id)519 Style::removeType(const std::string& id)
520 {
521 this->mTypeList.erase(id);
522 return LIBSBML_OPERATION_SUCCESS;
523 }
524
525
526 /*
527 * Sets the complete type list to a copy of the given list.
528 */
529 int
setTypeList(const std::set<std::string> & typeList)530 Style::setTypeList(const std::set<std::string>& typeList)
531 {
532 // I do not check types on purpose since this is more versatil in the light
533 // of future extensions
534 this->mTypeList=typeList;
535 return LIBSBML_OPERATION_SUCCESS;
536 }
537
538 /*
539 * Returns the value of the "group" element of this Style.
540 */
541 const RenderGroup*
getGroup() const542 Style::getGroup() const
543 {
544 return &this->mGroup;
545 }
546
547
548 /*
549 * Returns the value of the "group" element of this Style.
550 */
551 RenderGroup*
getGroup()552 Style::getGroup()
553 {
554 return &this->mGroup;
555 }
556
557
558 /*
559 * Predicate returning @c true if this Style's "group" element is set.
560 */
561 bool
isSetGroup() const562 Style::isSetGroup() const
563 {
564 return (&mGroup != NULL);
565 }
566
567
568 /*
569 * Sets the value of the "group" element of this Style.
570 */
571 int
setGroup(const RenderGroup * group)572 Style::setGroup(const RenderGroup* group)
573 {
574 if (&mGroup == group)
575 {
576 return LIBSBML_OPERATION_SUCCESS;
577 }
578 else if (group == NULL)
579 {
580 return LIBSBML_OPERATION_SUCCESS;
581 }
582 else
583 {
584 this->mGroup=*group;
585 return LIBSBML_OPERATION_SUCCESS;
586 }
587 }
588
589
590 /*
591 * Creates a new RenderGroup object, adds it to this Style object and returns
592 * the RenderGroup object created.
593 */
594 RenderGroup*
createGroup()595 Style::createGroup()
596 {
597 RENDER_CREATE_NS(renderns, getSBMLNamespaces());
598 RenderGroup *g = new RenderGroup(renderns);
599
600 g->setElementName("g");
601
602 delete renderns;
603 this->setGroup(g);
604
605 connectToChild();
606
607 return &mGroup;
608 }
609
610
611 /*
612 * Unsets the value of the "group" element of this Style.
613 */
614 int
unsetGroup()615 Style::unsetGroup()
616 {
617 return LIBSBML_OPERATION_SUCCESS;
618 }
619
620
621 /*
622 * Predicate returning @c true if this abstract Style is of type GlobalStyle
623 */
624 bool
isGlobalStyle() const625 Style::isGlobalStyle() const
626 {
627 return dynamic_cast<const GlobalStyle*>(this) != NULL;
628 }
629
630
631 /*
632 * Predicate returning @c true if this abstract Style is of type LocalStyle
633 */
634 bool
isLocalStyle() const635 Style::isLocalStyle() const
636 {
637 return dynamic_cast<const LocalStyle*>(this) != NULL;
638 }
639
640
641 /*
642 * Returns the XML element name of this Style object.
643 */
644 const std::string&
getElementName() const645 Style::getElementName() const
646 {
647 static const string name = "style";
648 return name;
649 }
650
651
652 /*
653 * Returns the libSBML type code for this Style object.
654 */
655 int
getTypeCode() const656 Style::getTypeCode() const
657 {
658 return SBML_RENDER_STYLE_BASE;
659 }
660
661
662 /*
663 * Predicate returning @c true if all the required attributes for this Style
664 * object have been set.
665 */
666 bool
hasRequiredAttributes() const667 Style::hasRequiredAttributes() const
668 {
669 bool allPresent = true;
670
671 return allPresent;
672 }
673
674
675
676 /** @cond doxygenLibsbmlInternal */
677
678 /*
679 * Write any contained elements
680 */
681 void
writeElements(XMLOutputStream & stream) const682 Style::writeElements(XMLOutputStream& stream) const
683 {
684 SBase::writeElements(stream);
685
686 mGroup.write(stream);
687
688 SBase::writeExtensionElements(stream);
689 }
690
691 /** @endcond */
692
693
694
695 /** @cond doxygenLibsbmlInternal */
696
697 /*
698 * Accepts the given SBMLVisitor
699 */
700 bool
accept(SBMLVisitor & v) const701 Style::accept(SBMLVisitor& v) const
702 {
703 v.visit(*this);
704
705 mGroup.accept(v);
706
707 v.leave(*this);
708 return true;
709 }
710
711 /** @endcond */
712
713
714
715 /** @cond doxygenLibsbmlInternal */
716
717 /*
718 * Sets the parent SBMLDocument
719 */
720 void
setSBMLDocument(SBMLDocument * d)721 Style::setSBMLDocument(SBMLDocument* d)
722 {
723 SBase::setSBMLDocument(d);
724
725 mGroup.setSBMLDocument(d);
726 }
727
728 /** @endcond */
729
730
731
732 /** @cond doxygenLibsbmlInternal */
733
734 /*
735 * Connects to child elements
736 */
737 void
connectToChild()738 Style::connectToChild()
739 {
740 SBase::connectToChild();
741
742 mGroup.connectToParent(this);
743 }
744
745 /** @endcond */
746
747
748
749 /** @cond doxygenLibsbmlInternal */
750
751 /*
752 * Enables/disables the given package with this element
753 */
754 void
enablePackageInternal(const std::string & pkgURI,const std::string & pkgPrefix,bool flag)755 Style::enablePackageInternal(const std::string& pkgURI,
756 const std::string& pkgPrefix,
757 bool flag)
758 {
759 SBase::enablePackageInternal(pkgURI, pkgPrefix, flag);
760
761 mGroup.enablePackageInternal(pkgURI, pkgPrefix, flag);
762 }
763
764 /** @endcond */
765
766
767
768 /** @cond doxygenLibsbmlInternal */
769
770 /*
771 * Returns the value of the "attributeName" attribute of this Style.
772 */
773 int
getAttribute(const std::string & attributeName,bool & value) const774 Style::getAttribute(const std::string& attributeName, bool& value) const
775 {
776 int return_value = SBase::getAttribute(attributeName, value);
777
778 return return_value;
779 }
780
781 /** @endcond */
782
783
784
785 /** @cond doxygenLibsbmlInternal */
786
787 /*
788 * Returns the value of the "attributeName" attribute of this Style.
789 */
790 int
getAttribute(const std::string & attributeName,int & value) const791 Style::getAttribute(const std::string& attributeName, int& value) const
792 {
793 int return_value = SBase::getAttribute(attributeName, value);
794
795 return return_value;
796 }
797
798 /** @endcond */
799
800
801
802 /** @cond doxygenLibsbmlInternal */
803
804 /*
805 * Returns the value of the "attributeName" attribute of this Style.
806 */
807 int
getAttribute(const std::string & attributeName,double & value) const808 Style::getAttribute(const std::string& attributeName, double& value) const
809 {
810 int return_value = SBase::getAttribute(attributeName, value);
811
812 return return_value;
813 }
814
815 /** @endcond */
816
817
818
819 /** @cond doxygenLibsbmlInternal */
820
821 /*
822 * Returns the value of the "attributeName" attribute of this Style.
823 */
824 int
getAttribute(const std::string & attributeName,unsigned int & value) const825 Style::getAttribute(const std::string& attributeName,
826 unsigned int& value) const
827 {
828 int return_value = SBase::getAttribute(attributeName, value);
829
830 return return_value;
831 }
832
833 /** @endcond */
834
835
836
837 /** @cond doxygenLibsbmlInternal */
838
839 /*
840 * Returns the value of the "attributeName" attribute of this Style.
841 */
842 int
getAttribute(const std::string & attributeName,std::string & value) const843 Style::getAttribute(const std::string& attributeName,
844 std::string& value) const
845 {
846 int return_value = SBase::getAttribute(attributeName, value);
847
848 if (return_value == LIBSBML_OPERATION_SUCCESS)
849 {
850 return return_value;
851 }
852
853 if (attributeName == "id")
854 {
855 value = getId();
856 return_value = LIBSBML_OPERATION_SUCCESS;
857 }
858 else if (attributeName == "name")
859 {
860 value = getName();
861 return_value = LIBSBML_OPERATION_SUCCESS;
862 }
863 //else if (attributeName == "roleList")
864 //{
865 // value = getRoleList();
866 // return_value = LIBSBML_OPERATION_SUCCESS;
867 //}
868 //else if (attributeName == "typeList")
869 //{
870 // value = getTypeList();
871 // return_value = LIBSBML_OPERATION_SUCCESS;
872 //}
873
874 return return_value;
875 }
876
877 /** @endcond */
878
879
880
881 /** @cond doxygenLibsbmlInternal */
882
883 /*
884 * Predicate returning @c true if this Style's attribute "attributeName" is
885 * set.
886 */
887 bool
isSetAttribute(const std::string & attributeName) const888 Style::isSetAttribute(const std::string& attributeName) const
889 {
890 bool value = SBase::isSetAttribute(attributeName);
891
892 if (attributeName == "id")
893 {
894 value = isSetId();
895 }
896 else if (attributeName == "name")
897 {
898 value = isSetName();
899 }
900 //else if (attributeName == "roleList")
901 //{
902 // value = isSetRoleList();
903 //}
904 //else if (attributeName == "typeList")
905 //{
906 // value = isSetTypeList();
907 //}
908
909 return value;
910 }
911
912 /** @endcond */
913
914
915
916 /** @cond doxygenLibsbmlInternal */
917
918 /*
919 * Sets the value of the "attributeName" attribute of this Style.
920 */
921 int
setAttribute(const std::string & attributeName,bool value)922 Style::setAttribute(const std::string& attributeName, bool value)
923 {
924 int return_value = SBase::setAttribute(attributeName, value);
925
926 return return_value;
927 }
928
929 /** @endcond */
930
931
932
933 /** @cond doxygenLibsbmlInternal */
934
935 /*
936 * Sets the value of the "attributeName" attribute of this Style.
937 */
938 int
setAttribute(const std::string & attributeName,int value)939 Style::setAttribute(const std::string& attributeName, int value)
940 {
941 int return_value = SBase::setAttribute(attributeName, value);
942
943 return return_value;
944 }
945
946 /** @endcond */
947
948
949
950 /** @cond doxygenLibsbmlInternal */
951
952 /*
953 * Sets the value of the "attributeName" attribute of this Style.
954 */
955 int
setAttribute(const std::string & attributeName,double value)956 Style::setAttribute(const std::string& attributeName, double value)
957 {
958 int return_value = SBase::setAttribute(attributeName, value);
959
960 return return_value;
961 }
962
963 /** @endcond */
964
965
966
967 /** @cond doxygenLibsbmlInternal */
968
969 /*
970 * Sets the value of the "attributeName" attribute of this Style.
971 */
972 int
setAttribute(const std::string & attributeName,unsigned int value)973 Style::setAttribute(const std::string& attributeName, unsigned int value)
974 {
975 int return_value = SBase::setAttribute(attributeName, value);
976
977 return return_value;
978 }
979
980 /** @endcond */
981
982
983
984 /** @cond doxygenLibsbmlInternal */
985
986 /*
987 * Sets the value of the "attributeName" attribute of this Style.
988 */
989 int
setAttribute(const std::string & attributeName,const std::string & value)990 Style::setAttribute(const std::string& attributeName,
991 const std::string& value)
992 {
993 int return_value = SBase::setAttribute(attributeName, value);
994
995 if (attributeName == "id")
996 {
997 return_value = setId(value);
998 }
999 else if (attributeName == "name")
1000 {
1001 return_value = setName(value);
1002 }
1003 //else if (attributeName == "roleList")
1004 //{
1005 // return_value = setRoleList(value);
1006 //}
1007 //else if (attributeName == "typeList")
1008 //{
1009 // return_value = setTypeList(value);
1010 //}
1011
1012 return return_value;
1013 }
1014
1015 /** @endcond */
1016
1017
1018
1019 /** @cond doxygenLibsbmlInternal */
1020
1021 /*
1022 * Unsets the value of the "attributeName" attribute of this Style.
1023 */
1024 int
unsetAttribute(const std::string & attributeName)1025 Style::unsetAttribute(const std::string& attributeName)
1026 {
1027 int value = SBase::unsetAttribute(attributeName);
1028
1029 if (attributeName == "id")
1030 {
1031 value = unsetId();
1032 }
1033 else if (attributeName == "name")
1034 {
1035 value = unsetName();
1036 }
1037 //else if (attributeName == "roleList")
1038 //{
1039 // value = unsetRoleList();
1040 //}
1041 //else if (attributeName == "typeList")
1042 //{
1043 // value = unsetTypeList();
1044 //}
1045
1046 return value;
1047 }
1048
1049 /** @endcond */
1050
1051
1052
1053 /** @cond doxygenLibsbmlInternal */
1054
1055 /*
1056 * Creates and returns an new "elementName" object in this Style.
1057 */
1058 SBase*
createChildObject(const std::string & elementName)1059 Style::createChildObject(const std::string& elementName)
1060 {
1061 SBase* obj = NULL;
1062
1063 if (elementName == "group")
1064 {
1065 return createGroup();
1066 }
1067
1068 return obj;
1069 }
1070
1071 /** @endcond */
1072
1073
1074
1075 /** @cond doxygenLibsbmlInternal */
1076
1077 /*
1078 * Adds a new "elementName" object to this Style.
1079 */
1080 int
addChildObject(const std::string & elementName,const SBase * element)1081 Style::addChildObject(const std::string& elementName, const SBase* element)
1082 {
1083 if (elementName == "group" && element->getTypeCode() == SBML_RENDER_GROUP)
1084 {
1085 return setGroup((const RenderGroup*)(element));
1086 }
1087
1088 return LIBSBML_OPERATION_FAILED;
1089 }
1090
1091 /** @endcond */
1092
1093
1094
1095 /** @cond doxygenLibsbmlInternal */
1096
1097 /*
1098 * Removes and returns the new "elementName" object with the given id in this
1099 * Style.
1100 */
1101 SBase*
removeChildObject(const std::string & elementName,const std::string & id)1102 Style::removeChildObject(const std::string& elementName,
1103 const std::string& id)
1104 {
1105 if (elementName == "group")
1106 {
1107 RenderGroup * obj = getGroup();
1108 if (unsetGroup() == LIBSBML_OPERATION_SUCCESS) return obj;
1109 }
1110
1111 return NULL;
1112 }
1113
1114 /** @endcond */
1115
1116
1117
1118 /** @cond doxygenLibsbmlInternal */
1119
1120 /*
1121 * Returns the number of "elementName" in this Style.
1122 */
1123 unsigned int
getNumObjects(const std::string & elementName)1124 Style::getNumObjects(const std::string& elementName)
1125 {
1126 unsigned int n = 0;
1127
1128 if (elementName == "group")
1129 {
1130 if (isSetGroup())
1131 {
1132 return 1;
1133 }
1134 }
1135
1136 return n;
1137 }
1138
1139 /** @endcond */
1140
1141
1142
1143 /** @cond doxygenLibsbmlInternal */
1144
1145 /*
1146 * Returns the nth object of "objectName" in this Style.
1147 */
1148 SBase*
getObject(const std::string & elementName,unsigned int index)1149 Style::getObject(const std::string& elementName, unsigned int index)
1150 {
1151 SBase* obj = NULL;
1152
1153 if (elementName == "group")
1154 {
1155 return getGroup();
1156 }
1157
1158 return obj;
1159 }
1160
1161 /** @endcond */
1162
1163
1164 /*
1165 * Returns the first child element that has the given @p id in the model-wide
1166 * SId namespace, or @c NULL if no such object is found.
1167 */
1168 SBase*
getElementBySId(const std::string & id)1169 Style::getElementBySId(const std::string& id)
1170 {
1171 if (id.empty())
1172 {
1173 return NULL;
1174 }
1175
1176 SBase* obj = NULL;
1177
1178 if (&mGroup != NULL)
1179 {
1180 if (mGroup.getId() == id)
1181 {
1182 return &mGroup;
1183 }
1184
1185 obj = mGroup.getElementBySId(id);
1186 if (obj != NULL)
1187 {
1188 return obj;
1189 }
1190 }
1191
1192 return obj;
1193 }
1194
1195
1196 /*
1197 * Returns the first child element that has the given @p metaid, or @c NULL if
1198 * no such object is found.
1199 */
1200 SBase*
getElementByMetaId(const std::string & metaid)1201 Style::getElementByMetaId(const std::string& metaid)
1202 {
1203 if (metaid.empty())
1204 {
1205 return NULL;
1206 }
1207
1208 SBase* obj = NULL;
1209
1210 if (&mGroup != NULL)
1211 {
1212 if (mGroup.getMetaId() == metaid)
1213 {
1214 return &mGroup;
1215 }
1216
1217 obj = mGroup.getElementByMetaId(metaid);
1218 if (obj != NULL)
1219 {
1220 return obj;
1221 }
1222 }
1223
1224 return obj;
1225 }
1226
1227
1228 /*
1229 * Returns a List of all child SBase objects, including those nested to an
1230 * arbitrary depth.
1231 */
1232 List*
getAllElements(ElementFilter * filter)1233 Style::getAllElements(ElementFilter* filter)
1234 {
1235 List* ret = new List();
1236 List* sublist = NULL;
1237
1238 ADD_FILTERED_ELEMENT(ret, sublist, mGroup, filter);
1239
1240
1241 ADD_FILTERED_FROM_PLUGIN(ret, sublist, filter);
1242
1243 return ret;
1244 }
1245
1246
1247 /*
1248 * Creates an XMLNode object from this Style object.
1249 */
toXML() const1250 XMLNode Style::toXML() const
1251 {
1252 return getXmlNodeForSBase(this);
1253 }
1254
1255
1256
1257 /** @cond doxygenLibsbmlInternal */
1258
1259 /*
1260 * Creates a new object from the next XMLToken on the XMLInputStream
1261 */
1262 SBase*
createObject(XMLInputStream & stream)1263 Style::createObject(XMLInputStream& stream)
1264 {
1265 SBase* obj = NULL;
1266
1267 const std::string& name = stream.peek().getName();
1268
1269 RENDER_CREATE_NS(renderns, getSBMLNamespaces());
1270
1271 if (name == "g")
1272 {
1273 // cannot check this here as a group is always set
1274 //if (isSetGroup())
1275 //{
1276 // getErrorLog()->logPackageError("render", RenderStyleAllowedElements,
1277 // getPackageVersion(), getLevel(), getVersion());
1278 //}
1279
1280 RenderGroup* g = new RenderGroup(renderns);
1281 g->setElementName(name);
1282 setGroup(g);
1283 obj = &mGroup;
1284 }
1285
1286 delete renderns;
1287
1288 connectToChild();
1289
1290 return obj;
1291 }
1292
1293 /** @endcond */
1294
1295
1296
1297 /** @cond doxygenLibsbmlInternal */
1298
1299 /*
1300 * Adds the expected attributes for this element
1301 */
1302 void
addExpectedAttributes(ExpectedAttributes & attributes)1303 Style::addExpectedAttributes(ExpectedAttributes& attributes)
1304 {
1305 SBase::addExpectedAttributes(attributes);
1306
1307 attributes.add("id");
1308
1309 attributes.add("name");
1310
1311 attributes.add("roleList");
1312
1313 attributes.add("typeList");
1314 }
1315
1316 /** @endcond */
1317
1318
1319
1320 /** @cond doxygenLibsbmlInternal */
1321
1322 /*
1323 * Reads the expected attributes into the member data variables
1324 */
1325 void
readAttributes(const XMLAttributes & attributes,const ExpectedAttributes & expectedAttributes)1326 Style::readAttributes(const XMLAttributes& attributes,
1327 const ExpectedAttributes& expectedAttributes)
1328 {
1329 unsigned int level = getLevel();
1330 unsigned int version = getVersion();
1331 unsigned int pkgVersion = getPackageVersion();
1332 unsigned int numErrs;
1333 bool assigned = false;
1334 SBMLErrorLog* log = getErrorLog();
1335
1336 SBase::readAttributes(attributes, expectedAttributes);
1337
1338 if (log)
1339 {
1340 numErrs = log->getNumErrors();
1341
1342 for (int n = numErrs - 1; n >= 0; n--)
1343 {
1344 if (log->getError(n)->getErrorId() == UnknownPackageAttribute)
1345 {
1346 const std::string details = log->getError(n)->getMessage();
1347 log->remove(UnknownPackageAttribute);
1348 log->logPackageError("render", RenderStyleAllowedAttributes,
1349 pkgVersion, level, version, details, getLine(), getColumn());
1350 }
1351 else if (log->getError(n)->getErrorId() == UnknownCoreAttribute)
1352 {
1353 const std::string details = log->getError(n)->getMessage();
1354 log->remove(UnknownCoreAttribute);
1355 log->logPackageError("render", RenderStyleAllowedCoreAttributes,
1356 pkgVersion, level, version, details, getLine(), getColumn());
1357 }
1358 }
1359 }
1360
1361 //
1362 // id SId (use = "optional" )
1363 //
1364
1365 assigned = attributes.readInto("id", mId);
1366
1367 if (log && assigned == true)
1368 {
1369 if (mId.empty() == true)
1370 {
1371 logEmptyString(mId, level, version, "<Style>");
1372 }
1373 else if (SyntaxChecker::isValidSBMLSId(mId) == false)
1374 {
1375 log->logPackageError("render", RenderIdSyntaxRule, pkgVersion, level,
1376 version, "The id on the <" + getElementName() + "> is '" + mId + "', "
1377 "which does not conform to the syntax.", getLine(), getColumn());
1378 }
1379 }
1380
1381 //
1382 // name string (use = "optional" )
1383 //
1384
1385 assigned = attributes.readInto("name", mName);
1386
1387 if (log && assigned == true)
1388 {
1389 if (mName.empty() == true)
1390 {
1391 logEmptyString(mName, level, version, "<Style>");
1392 }
1393 }
1394
1395 string elplusid = "<style> element";
1396 if (!getId().empty()) {
1397 elplusid += " with the id '" + mId + "'";
1398 }
1399 //
1400 // roleList string (use = "optional" )
1401 //
1402 readListOfRoles(attributes);
1403
1404 //
1405 // typeList string (use = "optional" )
1406 //
1407 readListOfTypes(attributes);
1408 }
1409
1410 /** @endcond */
1411
1412
1413
1414 /** @cond doxygenLibsbmlInternal */
1415
1416 /*
1417 * Writes the attributes to the stream
1418 */
1419 void
writeAttributes(XMLOutputStream & stream) const1420 Style::writeAttributes(XMLOutputStream& stream) const
1421 {
1422 SBase::writeAttributes(stream);
1423
1424 if (isSetId() == true)
1425 {
1426 stream.writeAttribute("id", getPrefix(), mId);
1427 }
1428
1429 if (isSetName() == true)
1430 {
1431 stream.writeAttribute("name", getPrefix(), mName);
1432 }
1433
1434 // write role list
1435 this->writeRolesList(stream);
1436 // write type list
1437 this->writeTypeList(stream);
1438
1439 SBase::writeExtensionAttributes(stream);
1440 }
1441
1442 /** @endcond */
1443
1444 /** @cond doxygenLibsbmlInternal */
readListOfRoles(const XMLAttributes & attr)1445 void Style::readListOfRoles(const XMLAttributes& attr)
1446 {
1447 std::string s;
1448 attr.readInto("roleList",s, getErrorLog(), false, getLine(), getColumn());
1449 // seperate the individual elements in the list
1450 // they are seperated by whitespaces
1451 if(!s.empty())
1452 {
1453 readIntoSet(s,this->mRoleList);
1454 }
1455 }
1456 /** @endcond */
1457
1458 /** @cond doxygenLibsbmlInternal */
readListOfTypes(const XMLAttributes & attr)1459 void Style::readListOfTypes(const XMLAttributes& attr)
1460 {
1461 std::string s;
1462 attr.readInto("typeList",s, getErrorLog(), false, getLine(), getColumn());
1463 // seperate the individual elements in the list
1464 // they are seperated by whitespaces
1465 if(!s.empty())
1466 {
1467 readIntoSet(s,this->mTypeList);
1468 }
1469 }
1470 /** @endcond */
1471
1472 /** @cond doxygenLibsbmlInternal */
1473 /*
1474 * Devides a string into individual elements and stores them in the given set.
1475 */
readIntoSet(const std::string & s,std::set<std::string> & set)1476 void Style::readIntoSet(const std::string& s,std::set<std::string>& set)
1477 {
1478 std::string delimiter="\n\r\t ";
1479 std::size_t lastPos=s.find_first_not_of(delimiter);
1480 std::size_t pos;
1481 while(lastPos!=std::string::npos)
1482 {
1483 pos=s.find_first_of(delimiter,lastPos);
1484 set.insert(s.substr(lastPos,pos-lastPos));
1485 lastPos=s.find_first_not_of(delimiter,pos);
1486 }
1487 }
1488 /** @endcond */
1489
1490 /** @cond doxygenLibsbmlInternal */
1491 /*
1492 * Concatenates individual elements from a set to a string.
1493 * The string is returned.
1494 */
createStringFromSet(const std::set<std::string> & set)1495 std::string Style::createStringFromSet(const std::set<std::string>& set)
1496 {
1497 std::ostringstream os;
1498 std::set<std::string>::const_iterator it=set.begin(),endit=set.end();
1499 while(it!=endit)
1500 {
1501 os << *it << " ";
1502 ++it;
1503 }
1504 if(!os.str().empty())
1505 {
1506 os.str(os.str().substr(0,os.str().size()-1));
1507 }
1508 return os.str();
1509 }
1510 /** @endcond */
1511
1512 /** @cond doxygenLibsbmlInternal */
1513 /*
1514 * Adds the typeList attribute to an XMLAttributes object.
1515 */
addListOfTypes(XMLAttributes & attr) const1516 void Style::addListOfTypes(XMLAttributes& attr) const
1517 {
1518 std::string s=createStringFromSet(this->mTypeList);
1519 if(!s.empty())
1520 {
1521 attr.add("typeList",s);
1522 }
1523 }
1524 /** @endcond */
1525
1526 /** @cond doxygenLibsbmlInternal */
1527 /*
1528 * Adds the typeList attribute to an XMLAttributes object.
1529 */
addListOfRoles(XMLAttributes & attr) const1530 void Style::addListOfRoles(XMLAttributes& attr) const
1531 {
1532 std::string s=createStringFromSet(this->mRoleList);
1533 if(!s.empty())
1534 {
1535 attr.add("roleList",s);
1536 }
1537 }
1538 /** @endcond */
1539
1540 /** @cond doxygenLibsbmlInternal */
1541 /*
1542 * Writes the type list to an XML stream.
1543 */
writeTypeList(XMLOutputStream & stream) const1544 void Style::writeTypeList(XMLOutputStream& stream) const
1545 {
1546 std::string s=createStringFromSet(this->mTypeList);
1547 if(!s.empty())
1548 {
1549 stream.writeAttribute("typeList", getPrefix(), s);
1550 }
1551 }
1552 /** @endcond */
1553
1554 /** @cond doxygenLibsbmlInternal */
1555 /*
1556 * Writes the role list to an XML stream.
1557 */
writeRolesList(XMLOutputStream & stream) const1558 void Style::writeRolesList(XMLOutputStream& stream) const
1559 {
1560 std::string s=createStringFromSet(this->mRoleList);
1561 if(!s.empty())
1562 {
1563 stream.writeAttribute("roleList", getPrefix(), s);
1564 }
1565 }
1566 /** @endcond */
1567
1568
1569
1570
1571 #endif /* __cplusplus */
1572
1573
1574 /*
1575 * Creates a new GlobalStyle (Style_t) using the given SBML Level, Version and
1576 * “render” package version.
1577 */
1578 LIBSBML_EXTERN
1579 Style_t *
Style_createGlobalStyle(unsigned int level,unsigned int version,unsigned int pkgVersion)1580 Style_createGlobalStyle(unsigned int level,
1581 unsigned int version,
1582 unsigned int pkgVersion)
1583 {
1584 return new GlobalStyle(level, version, pkgVersion);
1585 }
1586
1587
1588 /*
1589 * Creates a new LocalStyle (Style_t) using the given SBML Level, Version and
1590 * “render” package version.
1591 */
1592 LIBSBML_EXTERN
1593 Style_t *
Style_createLocalStyle(unsigned int level,unsigned int version,unsigned int pkgVersion)1594 Style_createLocalStyle(unsigned int level,
1595 unsigned int version,
1596 unsigned int pkgVersion)
1597 {
1598 return new LocalStyle(level, version, pkgVersion);
1599 }
1600
1601
1602 /*
1603 * Creates and returns a deep copy of this Style_t object.
1604 */
1605 LIBSBML_EXTERN
1606 Style_t*
Style_clone(const Style_t * s)1607 Style_clone(const Style_t* s)
1608 {
1609 if (s != NULL)
1610 {
1611 return static_cast<Style_t*>(s->clone());
1612 }
1613 else
1614 {
1615 return NULL;
1616 }
1617 }
1618
1619
1620 /*
1621 * Frees this Style_t object.
1622 */
1623 LIBSBML_EXTERN
1624 void
Style_free(Style_t * s)1625 Style_free(Style_t* s)
1626 {
1627 if (s != NULL)
1628 {
1629 delete s;
1630 }
1631 }
1632
1633
1634 /*
1635 * Returns the value of the "id" attribute of this Style_t.
1636 */
1637 LIBSBML_EXTERN
1638 char *
Style_getId(const Style_t * s)1639 Style_getId(const Style_t * s)
1640 {
1641 if (s == NULL)
1642 {
1643 return NULL;
1644 }
1645
1646 return s->getId().empty() ? NULL : safe_strdup(s->getId().c_str());
1647 }
1648
1649
1650 /*
1651 * Returns the value of the "name" attribute of this Style_t.
1652 */
1653 LIBSBML_EXTERN
1654 char *
Style_getName(const Style_t * s)1655 Style_getName(const Style_t * s)
1656 {
1657 if (s == NULL)
1658 {
1659 return NULL;
1660 }
1661
1662 return s->getName().empty() ? NULL : safe_strdup(s->getName().c_str());
1663 }
1664
1665
1666 ///*
1667 // * Returns the value of the "roleList" attribute of this Style_t.
1668 // */
1669 //LIBSBML_EXTERN
1670 //char *
1671 //Style_getRoleList(const Style_t * s)
1672 //{
1673 // if (s == NULL)
1674 // {
1675 // return NULL;
1676 // }
1677 //
1678 // return s->getRoleList().empty() ? NULL :
1679 // safe_strdup(s->getRoleList().c_str());
1680 //}
1681 //
1682 //
1683 ///*
1684 // * Returns the value of the "typeList" attribute of this Style_t.
1685 // */
1686 //LIBSBML_EXTERN
1687 //char *
1688 //Style_getTypeList(const Style_t * s)
1689 //{
1690 // if (s == NULL)
1691 // {
1692 // return NULL;
1693 // }
1694 //
1695 // return s->getTypeList().empty() ? NULL :
1696 // safe_strdup(s->getTypeList().c_str());
1697 //}
1698 //
1699 //
1700 /*
1701 * Predicate returning @c 1 (true) if this Style_t's "id" attribute is set.
1702 */
1703 LIBSBML_EXTERN
1704 int
Style_isSetId(const Style_t * s)1705 Style_isSetId(const Style_t * s)
1706 {
1707 return (s != NULL) ? static_cast<int>(s->isSetId()) : 0;
1708 }
1709
1710
1711 /*
1712 * Predicate returning @c 1 (true) if this Style_t's "name" attribute is set.
1713 */
1714 LIBSBML_EXTERN
1715 int
Style_isSetName(const Style_t * s)1716 Style_isSetName(const Style_t * s)
1717 {
1718 return (s != NULL) ? static_cast<int>(s->isSetName()) : 0;
1719 }
1720
1721
1722 /*
1723 * Sets the value of the "id" attribute of this Style_t.
1724 */
1725 LIBSBML_EXTERN
1726 int
Style_setId(Style_t * s,const char * id)1727 Style_setId(Style_t * s, const char * id)
1728 {
1729 return (s != NULL) ? s->setId(id) : LIBSBML_INVALID_OBJECT;
1730 }
1731
1732
1733 /*
1734 * Sets the value of the "name" attribute of this Style_t.
1735 */
1736 LIBSBML_EXTERN
1737 int
Style_setName(Style_t * s,const char * name)1738 Style_setName(Style_t * s, const char * name)
1739 {
1740 return (s != NULL) ? s->setName(name) : LIBSBML_INVALID_OBJECT;
1741 }
1742
1743
1744 /*
1745 * Sets the value of the "roleList" attribute of this Style_t.
1746 */
1747 LIBSBML_EXTERN
1748 int
Style_setRoleList(Style_t * s,const char * roleList)1749 Style_setRoleList(Style_t * s, const char * roleList)
1750 {
1751 return (s != NULL) ? s->addRole(roleList) : LIBSBML_INVALID_OBJECT;
1752 }
1753
1754
1755 /*
1756 * Sets the value of the "typeList" attribute of this Style_t.
1757 */
1758 LIBSBML_EXTERN
1759 int
Style_setTypeList(Style_t * s,const char * typeList)1760 Style_setTypeList(Style_t * s, const char * typeList)
1761 {
1762 return (s != NULL) ? s->addType(typeList) : LIBSBML_INVALID_OBJECT;
1763 }
1764
1765
1766 /*
1767 * Unsets the value of the "id" attribute of this Style_t.
1768 */
1769 LIBSBML_EXTERN
1770 int
Style_unsetId(Style_t * s)1771 Style_unsetId(Style_t * s)
1772 {
1773 return (s != NULL) ? s->unsetId() : LIBSBML_INVALID_OBJECT;
1774 }
1775
1776
1777 /*
1778 * Unsets the value of the "name" attribute of this Style_t.
1779 */
1780 LIBSBML_EXTERN
1781 int
Style_unsetName(Style_t * s)1782 Style_unsetName(Style_t * s)
1783 {
1784 return (s != NULL) ? s->unsetName() : LIBSBML_INVALID_OBJECT;
1785 }
1786
1787
1788
1789 /*
1790 * Returns the value of the "group" element of this Style_t.
1791 */
1792 LIBSBML_EXTERN
1793 const RenderGroup_t*
Style_getGroup(const Style_t * s)1794 Style_getGroup(const Style_t * s)
1795 {
1796 if (s == NULL)
1797 {
1798 return NULL;
1799 }
1800
1801 return (RenderGroup_t*)(s->getGroup());
1802 }
1803
1804
1805 /*
1806 * Predicate returning @c 1 (true) if this Style_t's "group" element is set.
1807 */
1808 LIBSBML_EXTERN
1809 int
Style_isSetGroup(const Style_t * s)1810 Style_isSetGroup(const Style_t * s)
1811 {
1812 return (s != NULL) ? static_cast<int>(s->isSetGroup()) : 0;
1813 }
1814
1815
1816 /*
1817 * Sets the value of the "group" element of this Style_t.
1818 */
1819 LIBSBML_EXTERN
1820 int
Style_setGroup(Style_t * s,const RenderGroup_t * group)1821 Style_setGroup(Style_t * s, const RenderGroup_t* group)
1822 {
1823 return (s != NULL) ? s->setGroup(group) : LIBSBML_INVALID_OBJECT;
1824 }
1825
1826
1827 /** @cond doxygenLibsbmlInternal */
1828 /*
1829 * Creates a new RenderGroup_t object, adds it to this Style_t object and
1830 * returns the RenderGroup_t object created.
1831 */
1832 LIBSBML_EXTERN
1833 RenderGroup_t*
Style_createGroup(Style_t * s)1834 Style_createGroup(Style_t* s)
1835 {
1836 if (s == NULL)
1837 {
1838 return NULL;
1839 }
1840
1841 return (RenderGroup_t*)(s->createGroup());
1842 }
1843 /** @endcond */
1844
1845
1846 /*
1847 * Unsets the value of the "group" element of this Style_t.
1848 */
1849 LIBSBML_EXTERN
1850 int
Style_unsetGroup(Style_t * s)1851 Style_unsetGroup(Style_t * s)
1852 {
1853 return (s != NULL) ? s->unsetGroup() : LIBSBML_INVALID_OBJECT;
1854 }
1855 /** @endcond */
1856
1857
1858 /*
1859 * Predicate returning @c 1 if this Style_t is of type GlobalStyle_t
1860 */
1861 LIBSBML_EXTERN
1862 int
Style_isGlobalStyle(const Style_t * s)1863 Style_isGlobalStyle(const Style_t * s)
1864 {
1865 return (s != NULL) ? static_cast<int>(s->isGlobalStyle()) : 0;
1866 }
1867
1868
1869 /*
1870 * Predicate returning @c 1 if this Style_t is of type LocalStyle_t
1871 */
1872 LIBSBML_EXTERN
1873 int
Style_isLocalStyle(const Style_t * s)1874 Style_isLocalStyle(const Style_t * s)
1875 {
1876 return (s != NULL) ? static_cast<int>(s->isLocalStyle()) : 0;
1877 }
1878
1879
1880 /*
1881 * Predicate returning @c 1 (true) if all the required attributes for this
1882 * Style_t object have been set.
1883 */
1884 LIBSBML_EXTERN
1885 int
Style_hasRequiredAttributes(const Style_t * s)1886 Style_hasRequiredAttributes(const Style_t * s)
1887 {
1888 return (s != NULL) ? static_cast<int>(s->hasRequiredAttributes()) : 0;
1889 }
1890
1891
1892
1893
1894 LIBSBML_CPP_NAMESPACE_END
1895
1896
1897