This file is indexed.

/usr/include/choreonoid-1.1/cnoid/src/Util/YamlWriter.h is in libcnoid-dev 1.1.0+dfsg-6.1+b4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
   @author Shin'ichiro Nakaoka
*/

#ifndef CNOID_UTIL_YAML_WRITER_H_INCLUDED
#define CNOID_UTIL_YAML_WRITER_H_INCLUDED

#include "YamlNodes.h"
#include <stack>
#include <string>
#include <fstream>
#include <boost/lexical_cast.hpp>
#include <boost/intrusive_ptr.hpp>
#include "exportdecl.h"

namespace cnoid {

    class CNOID_EXPORT YamlWriter
    {
    public:
        YamlWriter(const std::string filename);
        ~YamlWriter();

        void putNode(YamlNode& node);
        void putNode(const YamlNodePtr& node);

        void setIndentWidth(int n);
        void setKeyOrderPreservationMode(bool on);

        void startDocument();

        void putComment(const std::string& comment, bool doNewLine = true);

        void putString(const std::string& value);
        void putSingleQuotedString(const std::string& value);
        void putDoubleQuotedString(const std::string& value);
        void putBlockStyleString(const std::string& value, bool isLiteral);
        inline void putLiteralString(const std::string& value) { putBlockStyleString(value, true); }
        inline void putFoldedString(const std::string& value) { putBlockStyleString(value, false); }

        template <class DataType> inline void putScalar(const DataType& value){
            putString(boost::lexical_cast<std::string>(value));
        }

        void putScalar(const double& value);
        void setDoubleFormat(const char* format);

        void startMapping();
        void startFlowStyleMapping();
        
        void putKey(const std::string& key, YamlStringStyle style = YAML_PLAIN_STRING);
        
        template <class DataType> inline void putKeyValue(const std::string& key, const DataType& value){
            putKey(key);
            putScalar(value);
        }

        inline void putKeyValue(const std::string& key, const std::string& value){
            putKey(key);
            putDoubleQuotedString(value);
        }
            
        void endMapping();

        void startSequence();
        void startFlowStyleSequence();
        
        void endSequence();

      private:

        std::ofstream ofs;

        int indentWidth;
        bool isCurrentNewLine;
        int numDocuments;
        bool isKeyOrderPreservationMode;
        bool doInsertLineFeed;

        const char* doubleFormat;

        enum { TOP, MAPPING, SEQUENCE };

        struct State {
            int type;
            bool isFlowStyle;
            bool isKeyPut;
            bool hasValuesBeenPut;
            std::string indentString;
        };
        
        std::stack<State> states;

        State* current;

        bool isTopLevel();
        State& pushState(int type, bool isFlowStyle);
        void popState();
        void indent();
        void newLine();
        bool makeValuePutReady();
        bool startValuePut();
        void endValuePut();
        void putString_(const std::string& value);
        void putSingleQuotedString_(const std::string& value);
        void putDoubleQuotedString_(const std::string& value);
        void putKey_(const std::string& key, YamlStringStyle style);
        void startMappingSub(bool isFlowStyle);
        void startSequenceSub(bool isFlowStyle);
        void putMappingNode(const YamlMapping* mapping);
        void putSequenceNode(const YamlSequence* sequence);
    };
}


#endif