# How to set EnumerationNode using integer (Cvb++ 13.02.002)

**URL:** <https://forum.commonvisionblox.com/t/how-to-set-enumerationnode-using-integer-cvb-13-02-002/1020>\
**Category:** C++ API\
**Created:** [January 16, 2020, 2:10pm UTC](https://forum.commonvisionblox.com/t/how-to-set-enumerationnode-using-integer-cvb-13-02-002/1020 "2020-01-16T14:10:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![djusten](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@djusten](https://forum.commonvisionblox.com/u/djusten)\
**Post date:** [January 16, 2020, 2:10pm UTC](https://forum.commonvisionblox.com/t/how-to-set-enumerationnode-using-integer-cvb-13-02-002/1020/1 "2020-01-16T14:10:06Z")

</div>

Hi guys,

Is there a way to set EnumerationNode using integer? I would like to set PixelFormat using PFNC standard values.

E.g using node `Std::PixelFormat`:

```auto
...
//Getting pixelFormat node
auto node = deviceNodeMap->Node("Std::PixelFormat"); 
auto enumNode = std::dynamic_pointer_cast<Cvb::EnumerationNode>(node);      

//Getting the Entries is possible to print the values following PFNC standard and as string.
for (auto value : enumNode->Entries()) {
  cout << value->NumericValue() << endl;
  cout << value->SymbolicValue() << endl;
}

//To set the STRING value is possible to use SetValue()
enumNode->SetValue("Mono8");

```

I would like to use a similar SetValue() function but using PFNC standard value like `0x01080002` (Mono8).  
Does someone know a way or the proper way to set this node using integer?

Thank you in advance.

Bests,  
Diogo Justen

---

<div class="post-metadata">

**Author:** ![Andreas](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/andreas/32/75_2.png) [@Andreas](https://forum.commonvisionblox.com/u/Andreas)\
**Post date:** [January 16, 2020, 7:57pm UTC](https://forum.commonvisionblox.com/t/how-to-set-enumerationnode-using-integer-cvb-13-02-002/1020/2 "2020-01-16T19:57:57Z")

</div>

Hi @djusten

You can do;

```auto
void SetNumericValue(CvbEnumerationNode& enumerationNode, std::int64_t value)
{
  auto entries = enumerationNode.Entries()
  auto symbolicValue = std::find_if(entries.begin(), entries.end(), 
  [value](const Cvb::EnumEntryNodePtr& node)
  {
    return value == node->NumericValue();
  })->SymbolicValue();
 enumerationNode.SetValue(symbolicValue);
}

```

Please note, that I did not run the code so it might need some adjustments.

---

<div class="post-metadata">

**Author:** ![djusten](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@djusten](https://forum.commonvisionblox.com/u/djusten)\
**Post date:** [January 17, 2020, 2:15pm UTC](https://forum.commonvisionblox.com/t/how-to-set-enumerationnode-using-integer-cvb-13-02-002/1020/3 "2020-01-17T14:15:14Z")

</div>

Hi @Andreas,

Thank you for your help, what you suggested worked.  
The final code running look like this:

```auto
try
{
    auto enumNode = std::dynamic_pointer_cast<Cvb::EnumerationNode>(node);      
    auto entries = enumNode->Entries();                                         
    if (entries.empty())                                                        
    {                                                                           
      WARNING("Entries node empty");                                            
      return false;                                                             
    }                                                                           
                                                                                
    auto symbolicValue = std::find_if(entries.begin(), entries.end(),           
                           [value](const Cvb::EnumEntryNodePtr & node)          
    {                                                                           
      return value == node->NumericValue();                                     
    })->get()->SymbolicValue();                                                 
                                                                                
    if (symbolicValue.empty())                                                  
    {                                                                           
      WARNING("Invalid symbolic value");                                        
      return false;                                                             
    }                                                                           
                                                                                
    enumNode->SetValue(symbolicValue);                                          
}

```

Thanks!!  
Diogo Justen

---

<div class="post-metadata">

**Author:** ![parsd](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/parsd/32/7_2.png) [@parsd](https://forum.commonvisionblox.com/u/parsd)\
**Post date:** [January 17, 2020, 8:39pm UTC](https://forum.commonvisionblox.com/t/how-to-set-enumerationnode-using-integer-cvb-13-02-002/1020/4 "2020-01-17T20:39:11Z")

</div>

Just keep in mind: the integer value is not standardized in the GenICam Standard Features Naming Convention, only the string values are. This is why only the string version of `SetValue` is provided.

_PixelFormat_ has the Pixel Format Naming Convention, though, which also defines integer constants. Thus in this case it should be fine.
