| 2525 | } |
| 2526 | |
| 2527 | XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) : |
| 2528 | _elementJustOpened( false ), |
| 2529 | _stack(), |
| 2530 | _firstElement( true ), |
| 2531 | _fp( file ), |
| 2532 | _depth( depth ), |
| 2533 | _textDepth( -1 ), |
| 2534 | _processEntities( true ), |
| 2535 | _compactMode( compact ), |
| 2536 | _buffer() |
| 2537 | { |
| 2538 | for( int i=0; i<ENTITY_RANGE; ++i ) { |
| 2539 | _entityFlag[i] = false; |
| 2540 | _restrictedEntityFlag[i] = false; |
| 2541 | } |
| 2542 | for( int i=0; i<NUM_ENTITIES; ++i ) { |
| 2543 | const char entityValue = entities[i].value; |
| 2544 | const unsigned char flagIndex = static_cast<unsigned char>(entityValue); |
| 2545 | TIXMLASSERT( flagIndex < ENTITY_RANGE ); |
| 2546 | _entityFlag[flagIndex] = true; |
| 2547 | } |
| 2548 | _restrictedEntityFlag[static_cast<unsigned char>('&')] = true; |
| 2549 | _restrictedEntityFlag[static_cast<unsigned char>('<')] = true; |
| 2550 | _restrictedEntityFlag[static_cast<unsigned char>('>')] = true; // not required, but consistency is nice |
| 2551 | _buffer.Push( 0 ); |
| 2552 | } |
| 2553 | |
| 2554 | |
| 2555 | void XMLPrinter::Print( const char* format, ... ) |