2023-08-18 15:55:31 +08:00
|
|
|
import java.io.OutputStreamWriter;
|
|
|
|
|
2023-08-20 12:13:40 +08:00
|
|
|
public class IndentHelper {
|
|
|
|
public IndentHelper(OutputStreamWriter writer) {
|
2023-08-18 15:55:31 +08:00
|
|
|
mIndent = 0;
|
2023-08-19 00:03:00 +08:00
|
|
|
mWriter = writer;
|
2023-08-18 15:55:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private int mIndent;
|
|
|
|
private OutputStreamWriter mWriter;
|
|
|
|
|
|
|
|
public void inc() {
|
|
|
|
++mIndent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void dec() {
|
|
|
|
--mIndent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void indent() throws Exception {
|
|
|
|
mWriter.write("\n");
|
|
|
|
for (int i = 0; i < mIndent; ++i) {
|
|
|
|
mWriter.write("\t");
|
|
|
|
}
|
|
|
|
}
|
2023-08-20 12:13:40 +08:00
|
|
|
|
2023-08-18 15:55:31 +08:00
|
|
|
public void puts(String data) throws Exception {
|
|
|
|
indent();
|
|
|
|
mWriter.write(data);
|
|
|
|
}
|
2023-08-20 12:13:40 +08:00
|
|
|
|
2023-08-18 15:55:31 +08:00
|
|
|
public void printf(String fmt, Object... args) throws Exception {
|
|
|
|
indent();
|
|
|
|
mWriter.write(String.format(fmt, args));
|
|
|
|
}
|
2023-08-20 12:13:40 +08:00
|
|
|
|
2023-08-20 16:10:22 +08:00
|
|
|
/**
|
|
|
|
* Write standard Doxygen document comment.
|
|
|
|
* <p>
|
|
|
|
* Usually be called before writing content.
|
|
|
|
* @param comment
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2023-08-20 12:13:40 +08:00
|
|
|
public void briefComment(String comment) throws Exception {
|
|
|
|
if (comment == null)
|
|
|
|
return;
|
2023-08-19 00:03:00 +08:00
|
|
|
puts("/**");
|
2023-08-20 12:13:40 +08:00
|
|
|
puts(comment);
|
2023-08-19 00:03:00 +08:00
|
|
|
puts(" */");
|
2023-08-18 15:55:31 +08:00
|
|
|
}
|
2023-08-20 12:13:40 +08:00
|
|
|
|
2023-08-20 16:10:22 +08:00
|
|
|
/**
|
|
|
|
* Write suffix style Doxygen document comment.
|
|
|
|
* <p>
|
|
|
|
* Usually be called after writing content.
|
|
|
|
* @param comment
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2023-08-20 12:13:40 +08:00
|
|
|
public void afterMemberComment(String comment) throws Exception {
|
|
|
|
if (comment == null)
|
|
|
|
return;
|
|
|
|
mWriter.write(String.format("\t/**< %s */", CommonHelper.removeEol(comment)));
|
2023-08-18 15:55:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|