2023-10-09 17:24:40 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2023-10-09 20:23:03 +00:00
|
|
|
main(int argc, char *argv[])
|
2023-10-09 17:24:40 +00:00
|
|
|
{
|
2023-10-09 20:23:03 +00:00
|
|
|
(void)argc; (void)argv;
|
|
|
|
|
2023-10-09 17:24:40 +00:00
|
|
|
klib::Buffer buffer("hlo, world");
|
|
|
|
|
|
|
|
std::cout << buffer.Contents() << std::endl;
|
|
|
|
|
|
|
|
buffer.Insert(1, (uint8_t *)"el", 2);
|
2023-10-09 19:45:19 +00:00
|
|
|
buffer.Append('!');
|
2023-10-09 17:24:40 +00:00
|
|
|
|
|
|
|
std::cout << buffer.Contents() << std::endl;
|
2023-10-09 19:45:19 +00:00
|
|
|
|
|
|
|
buffer.Remove(buffer.Length()-1);
|
|
|
|
buffer.Remove(0, 5);
|
|
|
|
buffer.Insert(0, 'g');
|
|
|
|
buffer.Insert(1, (uint8_t *)"oodbye", 6);
|
|
|
|
|
|
|
|
buffer.Reclaim();
|
|
|
|
buffer.Append("and now for something completely different...");
|
|
|
|
|
|
|
|
std::cout << buffer.Contents() << std::endl;
|
2023-10-09 20:16:05 +00:00
|
|
|
std::cout << "Length: " << buffer.Length() << ", capacity " << buffer.Capacity() << std::endl;
|
|
|
|
buffer.Resize(128);
|
|
|
|
std::cout << "Length: " << buffer.Length() << ", capacity " << buffer.Capacity() << std::endl;
|
|
|
|
buffer.Trim();
|
|
|
|
std::cout << "Length: " << buffer.Length() << ", capacity " << buffer.Capacity() << std::endl;
|
2023-10-09 19:45:19 +00:00
|
|
|
|
2023-10-09 20:16:05 +00:00
|
|
|
|
|
|
|
return 0;
|
2023-10-09 17:24:40 +00:00
|
|
|
}
|