
Definition at line 56 of file Properties.cpp.
| PropertiesImpl::PropertiesImpl | ( | const PropertiesImpl & | ) | [private] |
| PropertiesImpl::PropertiesImpl | ( | Properties * | p, | |
| bool | case_insensitive | |||
| ) |
Methods for PropertiesImpl
Definition at line 484 of file Properties.cpp.
References content, items, p, properties, setCaseInsensitiveNames(), and size.
00484 { 00485 this->properties = p; 00486 items = 0; 00487 size = 25; 00488 content = new PropertyImpl * [size]; 00489 setCaseInsensitiveNames(case_insensitive); 00490 }
Here is the call graph for this function:

| PropertiesImpl::PropertiesImpl | ( | Properties * | , | |
| const PropertiesImpl & | ||||
| ) |
Definition at line 492 of file Properties.cpp.
References compare, content, PropertyImpl::copyPropertyImpl(), items, m_insensitive, p, properties, and size.
00492 { 00493 this->properties = p; 00494 this->size = org.size; 00495 this->items = org.items; 00496 this->m_insensitive = org.m_insensitive; 00497 this->compare = org.compare; 00498 content = new PropertyImpl * [size]; 00499 for(unsigned int i = 0; i<items; i++){ 00500 content[i] = PropertyImpl::copyPropertyImpl(* org.content[i]); 00501 } 00502 }
Here is the call graph for this function:

| PropertiesImpl::~PropertiesImpl | ( | ) |
| PropertyImpl * PropertiesImpl::get | ( | const char * | name | ) | const |
Definition at line 529 of file Properties.cpp.
References compare, content, getProps(), items, and PropertyImpl::name.
Referenced by Properties::contains(), Properties::get(), Properties::getCopy(), getProps(), getPropsPut(), Properties::getTypeOf(), and put().
00529 { 00530 const PropertiesImpl * tmp = 0; 00531 const char * short_name = getProps(name, &tmp); 00532 if(tmp == 0){ 00533 return 0; 00534 } 00535 00536 for(unsigned int i = 0; i<tmp->items; i++) { 00537 if((* compare)(tmp->content[i]->name, short_name) == 0) 00538 return tmp->content[i]; 00539 } 00540 00541 return 0; 00542 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 653 of file Properties.cpp.
References assert, content, items, mod4(), name, p, PropertiesType_char, PropertiesType_Properties, PropertiesType_Uint32, PropertiesType_Uint64, strlen(), and value.
Referenced by Properties::getPackedSize().
00653 { 00654 Uint32 sz = 0; 00655 for(unsigned int i = 0; i<items; i++){ 00656 if(content[i]->valueType == PropertiesType_Properties){ 00657 Properties * p = (Properties*)content[i]->value; 00658 sz += p->impl->getPackedSize(pLen+strlen(content[i]->name)+1); 00659 } else { 00660 sz += 4; // Type 00661 sz += 4; // Name Len 00662 sz += 4; // Value Len 00663 sz += mod4(pLen + strlen(content[i]->name)); // Name 00664 switch(content[i]->valueType){ 00665 case PropertiesType_char: 00666 sz += mod4(strlen((char *)content[i]->value)); 00667 break; 00668 case PropertiesType_Uint32: 00669 sz += mod4(4); 00670 break; 00671 case PropertiesType_Uint64: 00672 sz += mod4(8); 00673 break; 00674 case PropertiesType_Properties: 00675 default: 00676 assert(0); 00677 } 00678 } 00679 } 00680 return sz; 00681 }
Here is the call graph for this function:

Here is the caller graph for this function:

| const char * PropertiesImpl::getProps | ( | const char * | name, | |
| const PropertiesImpl ** | impl | |||
| ) | const |
Definition at line 583 of file Properties.cpp.
References Properties::delimiter, free, get(), getProps(), malloc, memcpy, PropertiesType_Properties, strchr(), PropertyImpl::value, and PropertyImpl::valueType.
Referenced by get(), and getProps().
00584 { 00585 const char * ret = name; 00586 const char * tmp = strchr(name, Properties::delimiter); 00587 if(tmp == 0){ 00588 * impl = this; 00589 return ret; 00590 } else { 00591 Uint32 sz = tmp - name; 00592 char * tmp2 = (char*)malloc(sz + 1); 00593 memcpy(tmp2, name, sz); 00594 tmp2[sz] = 0; 00595 00596 PropertyImpl * nvp = get(tmp2); 00597 00598 free(tmp2); 00599 00600 if(nvp == 0){ 00601 * impl = 0; 00602 return 0; 00603 } 00604 if(nvp->valueType != PropertiesType_Properties){ 00605 * impl = 0; 00606 return name; 00607 } 00608 return ((Properties*)nvp->value)->impl->getProps(tmp+1, impl); 00609 } 00610 }
Here is the call graph for this function:

Here is the caller graph for this function:

| const char * PropertiesImpl::getPropsPut | ( | const char * | name, | |
| PropertiesImpl ** | impl | |||
| ) |
Definition at line 613 of file Properties.cpp.
References Properties::delimiter, free, get(), getPropsPut(), malloc, memcpy, PropertiesType_Properties, put(), strchr(), PropertyImpl::value, and PropertyImpl::valueType.
Referenced by getPropsPut(), and put().
00614 { 00615 const char * ret = name; 00616 const char * tmp = strchr(name, Properties::delimiter); 00617 if(tmp == 0){ 00618 * impl = this; 00619 return ret; 00620 } else { 00621 Uint32 sz = tmp - name; 00622 char * tmp2 = (char*)malloc(sz + 1); 00623 memcpy(tmp2, name, sz); 00624 tmp2[sz] = 0; 00625 00626 PropertyImpl * nvp = get(tmp2); 00627 00628 if(nvp == 0){ 00629 Properties * tmpP = new Properties(); 00630 PropertyImpl * tmpPI = new PropertyImpl(tmp2, tmpP); 00631 PropertyImpl * nvp = put(tmpPI); 00632 00633 delete tmpP; 00634 free(tmp2); 00635 return ((Properties*)nvp->value)->impl->getPropsPut(tmp+1, impl); 00636 } 00637 free(tmp2); 00638 if(nvp->valueType != PropertiesType_Properties){ 00639 * impl = 0; 00640 return name; 00641 } 00642 return ((Properties*)nvp->value)->impl->getPropsPut(tmp+1, impl); 00643 } 00644 }
Here is the call graph for this function:

Here is the caller graph for this function:

| Uint32 PropertiesImpl::getTotalItems | ( | ) | const |
Definition at line 571 of file Properties.cpp.
References content, items, PropertiesType_Properties, and value.
Referenced by Properties::pack().
00571 { 00572 int ret = 0; 00573 for(unsigned int i = 0; i<items; i++) 00574 if(content[i]->valueType == PropertiesType_Properties){ 00575 ret += ((Properties*)content[i]->value)->impl->getTotalItems(); 00576 } else { 00577 ret ++; 00578 } 00579 return ret; 00580 }
Here is the caller graph for this function:

| void PropertiesImpl::grow | ( | int | sizeToAdd | ) |
Definition at line 520 of file Properties.cpp.
References content, items, memcpy, and size.
Referenced by put().
00520 { 00521 PropertyImpl ** newContent = new PropertyImpl * [size + sizeToAdd]; 00522 memcpy(newContent, content, items * sizeof(PropertyImpl *)); 00523 delete [] content; 00524 content = newContent; 00525 size += sizeToAdd; 00526 }
Here is the caller graph for this function:

| PropertiesImpl& PropertiesImpl::operator= | ( | const PropertiesImpl & | ) | [private] |
Definition at line 731 of file Properties.cpp.
References CharBuf::add(), assert, CharBuf::buffer, CharBuf::clear(), content, CharBuf::contentLen, Properties::delimiter, E_PROPERTIES_ERROR_MALLOC_WHILE_PACKING, errno, items, memcpy, memset, mod4(), PropertyImpl::name, name, properties, PropertiesType_char, PropertiesType_Properties, PropertiesType_Uint32, PropertiesType_Uint64, Properties::setErrno(), strlen(), and value.
Referenced by Properties::pack().
00731 { 00732 CharBuf charBuf; 00733 00734 for(unsigned int i = 0; i<items; i++){ 00735 const int strLenName = strlen(content[i]->name); 00736 00737 if(content[i]->valueType == PropertiesType_Properties){ 00738 charBuf.clear(); 00739 if(!charBuf.add(prefix, pLen)){ 00740 properties->setErrno(E_PROPERTIES_ERROR_MALLOC_WHILE_PACKING, 00741 errno); 00742 return false; 00743 } 00744 00745 if(!charBuf.add(content[i]->name, strLenName)){ 00746 properties->setErrno(E_PROPERTIES_ERROR_MALLOC_WHILE_PACKING, 00747 errno); 00748 return false; 00749 } 00750 00751 if(!charBuf.add(Properties::delimiter)){ 00752 properties->setErrno(E_PROPERTIES_ERROR_MALLOC_WHILE_PACKING, 00753 errno); 00754 return false; 00755 } 00756 00757 if(!((Properties*)(content[i]->value))->impl->pack(buf, 00758 charBuf.buffer, 00759 charBuf.contentLen)){ 00760 00761 return false; 00762 } 00763 continue; 00764 } 00765 00766 Uint32 valLenData = 0; 00767 Uint32 valLenWrite = 0; 00768 Uint32 sz = 4 + 4 + 4 + mod4(pLen + strLenName); 00769 switch(content[i]->valueType){ 00770 case PropertiesType_Uint32: 00771 valLenData = 4; 00772 break; 00773 case PropertiesType_Uint64: 00774 valLenData = 8; 00775 break; 00776 case PropertiesType_char: 00777 valLenData = strlen((char *)content[i]->value); 00778 break; 00779 case PropertiesType_Properties: 00780 assert(0); 00781 } 00782 valLenWrite = mod4(valLenData); 00783 sz += valLenWrite; 00784 00785 * (buf + 0) = htonl(content[i]->valueType); 00786 * (buf + 1) = htonl(pLen + strLenName); 00787 * (buf + 2) = htonl(valLenData); 00788 00789 char * valBuf = (char*)(buf + 3); 00790 char * nameBuf = (char*)(buf + 3 + (valLenWrite / 4)); 00791 00792 memset(valBuf, 0, sz-12); 00793 00794 switch(content[i]->valueType){ 00795 case PropertiesType_Uint32: 00796 * (Uint32 *)valBuf = htonl(* (Uint32 *)content[i]->value); 00797 break; 00798 case PropertiesType_Uint64:{ 00799 Uint64 val = * (Uint64 *)content[i]->value; 00800 Uint32 hi = (val >> 32); 00801 Uint32 lo = (val & 0xFFFFFFFF); 00802 * (Uint32 *)valBuf = htonl(hi); 00803 * (Uint32 *)(valBuf + 4) = htonl(lo); 00804 } 00805 break; 00806 case PropertiesType_char: 00807 memcpy(valBuf, content[i]->value, strlen((char*)content[i]->value)); 00808 break; 00809 case PropertiesType_Properties: 00810 assert(0); 00811 } 00812 if(pLen > 0) 00813 memcpy(nameBuf, prefix, pLen); 00814 memcpy(nameBuf + pLen, content[i]->name, strLenName); 00815 00816 buf += (sz / 4); 00817 } 00818 00819 return true; 00820 }
Here is the call graph for this function:

Here is the caller graph for this function:

| PropertyImpl * PropertiesImpl::put | ( | PropertyImpl * | ) |
Definition at line 545 of file Properties.cpp.
References content, grow(), items, properties, PropertiesType_Properties, size, PropertyImpl::value, and PropertyImpl::valueType.
Referenced by getPropsPut(), put(), and Properties::put().
00545 { 00546 if(items == size) 00547 grow(size); 00548 content[items] = nvp; 00549 00550 items ++; 00551 00552 if(nvp->valueType == PropertiesType_Properties){ 00553 ((Properties*)nvp->value)->parent = properties; 00554 } 00555 return nvp; 00556 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void PropertiesImpl::remove | ( | const char * | name | ) |
Definition at line 559 of file Properties.cpp.
References compare, content, items, and memmove.
Referenced by Properties::clear(), put(), and Properties::remove().
00559 { 00560 for(unsigned int i = 0; i<items; i++){ 00561 if((* compare)(content[i]->name, name) == 0){ 00562 delete content[i]; 00563 memmove(&content[i], &content[i+1], (items-i-1)*sizeof(PropertyImpl *)); 00564 items --; 00565 return; 00566 } 00567 } 00568 }
Here is the caller graph for this function:

| void PropertiesImpl::setCaseInsensitiveNames | ( | bool | value | ) |
Definition at line 511 of file Properties.cpp.
References compare, m_insensitive, strcasecmp, and strcmp().
Referenced by PropertiesImpl(), and Properties::setCaseInsensitiveNames().
00511 { 00512 m_insensitive = value; 00513 if(value) 00514 compare = strcasecmp; 00515 else 00516 compare = strcmp; 00517 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 86 of file Properties.cpp.
References properties, and Properties::setErrno().
Referenced by put().
00086 { 00087 properties->setErrno(pErr, osErr); 00088 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool PropertiesImpl::unpack | ( | const Uint32 * | buf, | |
| Uint32 & | bufLen, | |||
| Properties * | top, | |||
| int | items | |||
| ) |
Definition at line 823 of file Properties.cpp.
References assert, CharBuf::buffer, E_PROPERTIES_BUFFER_TO_SMALL_WHILE_UNPACKING, E_PROPERTIES_ERROR_MALLOC_WHILE_UNPACKING, errno, CharBuf::expand(), memcpy, mod4(), PropertiesType_char, PropertiesType_Properties, PropertiesType_Uint32, PropertiesType_Uint64, Properties::put(), Properties::put64(), and Properties::setErrno().
Referenced by Properties::unpack().
00824 { 00825 CharBuf charBuf; 00826 while(_items > 0){ 00827 Uint32 tmp[3]; 00828 00829 if(bufLen <= 12){ 00830 top->setErrno(E_PROPERTIES_BUFFER_TO_SMALL_WHILE_UNPACKING); 00831 return false; 00832 } 00833 00834 tmp[0] = ntohl(buf[0]); 00835 tmp[1] = ntohl(buf[1]); 00836 tmp[2] = ntohl(buf[2]); 00837 buf += 3; 00838 bufLen -= 12; 00839 00840 PropertiesType pt = (PropertiesType)tmp[0]; 00841 Uint32 nameLen = tmp[1]; 00842 Uint32 valueLen = tmp[2]; 00843 Uint32 nameLenRead = mod4(nameLen); 00844 Uint32 valueLenRead = mod4(valueLen); 00845 00846 Uint32 sz = nameLenRead + valueLenRead; 00847 if(bufLen < sz){ 00848 top->setErrno(E_PROPERTIES_BUFFER_TO_SMALL_WHILE_UNPACKING); 00849 return false; 00850 } 00851 00852 if(!charBuf.expand(sz)){ 00853 top->setErrno(E_PROPERTIES_ERROR_MALLOC_WHILE_UNPACKING, errno); 00854 return false; 00855 } 00856 00857 memcpy(charBuf.buffer, buf, sz); 00858 buf += (sz / 4); 00859 bufLen -= sz ; 00860 00861 char * valBuf = charBuf.buffer; 00862 char * nameBuf = charBuf.buffer + valueLenRead; 00863 00864 nameBuf[nameLen] = 0; 00865 valBuf[valueLen] = 0; 00866 00867 bool res3 = false; 00868 switch(pt){ 00869 case PropertiesType_Uint32: 00870 res3 = top->put(nameBuf, ntohl(* (Uint32 *)valBuf), true); 00871 break; 00872 case PropertiesType_Uint64:{ 00873 Uint64 hi = ntohl(* (Uint32 *)valBuf); 00874 Uint64 lo = ntohl(* (Uint32 *)(valBuf + 4)); 00875 res3 = top->put64(nameBuf, (hi << 32) + lo, true); 00876 } 00877 break; 00878 case PropertiesType_char: 00879 res3 = top->put(nameBuf, valBuf, true); 00880 break; 00881 case PropertiesType_Properties: 00882 assert(0); 00883 } 00884 if(!res3){ 00885 return false; 00886 } 00887 _items--; 00888 } 00889 return true; 00890 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int(* PropertiesImpl::compare)(const char *s1, const char *s2) |
Referenced by get(), PropertiesImpl(), remove(), and setCaseInsensitiveNames().
Definition at line 68 of file Properties.cpp.
Referenced by Properties::clear(), get(), getPackedSize(), getTotalItems(), grow(), Properties::Iterator::next(), pack(), Properties::print(), PropertiesImpl(), put(), remove(), and ~PropertiesImpl().
Definition at line 67 of file Properties.cpp.
Referenced by Properties::clear(), get(), getPackedSize(), getTotalItems(), grow(), Properties::Iterator::next(), pack(), Properties::print(), PropertiesImpl(), put(), remove(), and ~PropertiesImpl().
Definition at line 70 of file Properties.cpp.
Referenced by Properties::getCaseInsensitiveNames(), PropertiesImpl(), and setCaseInsensitiveNames().
Definition at line 64 of file Properties.cpp.
Referenced by pack(), PropertiesImpl(), put(), and setErrno().
1.4.7

